Skip to content

Commit f40631c

Browse files
author
Federico Fissore
committed
Added ISDIRECTORY command
1 parent 10d4da4 commit f40631c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

linux/bridge/files.py

100755100644
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def tell(self, id):
6565
return [0, file.tell()]
6666
except IOError, e:
6767
return [e.errno, None]
68+
69+
def isDir(self, filename):
70+
from os import path
71+
return path.isdir(filename)
72+
6873

6974
files = Files()
7075

@@ -124,12 +129,24 @@ def run(self, data):
124129
res += chr((pos>>8) & 0xFF)
125130
res += chr(pos & 0xFF)
126131
return res
132+
133+
134+
class ISDIRECTORY_Command:
135+
def run(self, data):
136+
filename = data[0:]
137+
if files.isDir(filename) is True:
138+
return chr(1)
139+
else:
140+
return chr(0)
141+
142+
127143

128144
def init(command_processor):
129145
command_processor.register('F', OPEN_Command())
130146
command_processor.register('f', CLOSE_Command())
131147
command_processor.register('G', READ_Command())
132148
command_processor.register('g', WRITE_Command())
149+
command_processor.register('i', ISDIRECTORY_Command())
133150
command_processor.register('s', SEEK_Command())
134151
command_processor.register('S', TELL_Command())
135152

0 commit comments

Comments
 (0)