PageRenderTime 68ms CodeModel.GetById 61ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/browser/MkDirBrowserTask.java

#
Java | 97 lines | 54 code | 8 blank | 35 comment | 1 complexity | 7f9f2ad2ac71446c2147ccbfdb049596 MD5 | raw file
 1/*
 2 * jEdit - Programmer's Text Editor
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright Š 2011 Matthieu Casanova
 7 * Portions Copyright (C) 2000, 2003 Slava Pestov
 8 *
 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23package org.gjt.sp.jedit.browser;
24
25//{{{ Imports
26import org.gjt.sp.jedit.io.VFS;
27import org.gjt.sp.jedit.io.VFSManager;
28import org.gjt.sp.jedit.jEdit;
29import org.gjt.sp.util.Log;
30
31import java.io.IOException;
32//}}}
33
34/**
35 * @author Matthieu CAsanova
36 * @version $Id: BrowserIORequest.java 12504 2008-04-22 23:12:43Z ezust $
37 */
38class MkDirBrowserTask extends AbstractBrowserTask
39{
40	//{{{ MkDirBrowserTask constructor
41	/**
42	 * Creates a new browser I/O request.
43	 * @param browser The VFS browser instance
44	 * @param path The first path name to operate on
45	 */
46	MkDirBrowserTask(VFSBrowser browser,
47			 Object session, VFS vfs, String path,
48			 Runnable awtRunnable)
49	{
50		super(browser, session, vfs, path, awtRunnable);
51	} //}}}
52
53	//{{{ run() method
54	@Override
55	public void _run()
56	{
57		String[] args = {path};
58		try
59		{
60			setCancellable(true);
61			setStatus(jEdit.getProperty("vfs.status.mkdir",args));
62
63			path = vfs._canonPath(session, path,browser);
64
65			if(!vfs._mkdir(session, path,browser))
66				VFSManager.error(browser, path,"ioerror.mkdir-error",null);
67		}
68		catch(IOException io)
69		{
70			setCancellable(false);
71			Log.log(Log.ERROR,this,io);
72			args[0] = io.toString();
73			VFSManager.error(browser, path,"ioerror",args);
74		}
75		finally
76		{
77			try
78			{
79				vfs._endVFSSession(session,browser);
80			}
81			catch(IOException io)
82			{
83				setCancellable(false);
84				Log.log(Log.ERROR,this,io);
85				args[0] = io.toString();
86				VFSManager.error(browser, path,"ioerror",args);
87			}
88		}
89	} //}}}
90
91	//{{{ toString() method
92	public String toString()
93	{
94		return getClass().getName() + "[type=MKDIR"
95			+ ",vfs=" + vfs + ",path=" + path + ']';
96	} //}}}
97}