summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-14 19:32:02 +0100
committerhut <hut@lavabit.com>2010-01-14 19:32:02 +0100
commit301b488b987b629add14c8a4831d237387ac5d28 (patch)
tree139b39c0b95c82fa0fc23e3ff7f13b1a05e9d824
parentc0280bc867aecc29d8f72fbbd637133ea88729ba (diff)
downloadranger-301b488b987b629add14c8a4831d237387ac5d28.tar.gz
commands: added touch, improved mkdir
-rw-r--r--ranger/commands.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/ranger/commands.py b/ranger/commands.py
index 411408eb..07c0a8d7 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -264,11 +264,34 @@ class mkdir(Command):
 	"""
 
 	def execute(self):
+		from os.path import join, expanduser, lexists
+		from os import mkdir
+
 		line = parse(self.line)
-		try:
-			self.fm.mkdir(line.rest(1))
-		except IndexError:
-			pass
+		dirname = join(self.fm.env.pwd.path, expanduser(line.rest(1)))
+		if not lexists(dirname):
+			mkdir(dirname)
+		else:
+			self.fm.notify("file/directory exists!", bad=True)
+
+
+class touch(Command):
+	"""
+	:touch <fname>
+
+	Creates a file with the name <fname>.
+	"""
+
+	def execute(self):
+		from os.path import join, expanduser, lexists
+		from os import mkdir
+
+		line = parse(self.line)
+		fname = join(self.fm.env.pwd.path, expanduser(line.rest(1)))
+		if not lexists(fname):
+			open(fname, 'a')
+		else:
+			self.fm.notify("file/directory exists!", bad=True)
 
 
 class edit(Command):