39 |
hardlinks = None # True if hard linking supported |
hardlinks = None # True if hard linking supported |
40 |
fsync_dirs = None # True if directories can be fsync'd |
fsync_dirs = None # True if directories can be fsync'd |
41 |
dir_inc_perms = None # True if regular files can have full permissions |
dir_inc_perms = None # True if regular files can have full permissions |
42 |
resource_forks = None # True if regular_file/rsrc holds resource fork |
resource_forks = None # True if regular_file/..namedfork/rsrc holds resource fork |
43 |
carbonfile = None # True if Mac Carbon file data is supported. |
carbonfile = None # True if Mac Carbon file data is supported. |
44 |
name = None # Short string, not used for any technical purpose |
name = None # Short string, not used for any technical purpose |
45 |
read_only = None # True if capabilities were determined non-destructively |
read_only = None # True if capabilities were determined non-destructively |
341 |
self.carbonfile = 1 |
self.carbonfile = 1 |
342 |
|
|
343 |
def set_resource_fork_readwrite(self, dir_rp): |
def set_resource_fork_readwrite(self, dir_rp): |
344 |
"""Test for resource forks by writing to regular_file/rsrc""" |
"""Test for resource forks by writing to regular_file/..namedfork/rsrc""" |
345 |
assert dir_rp.conn is Globals.local_connection |
assert dir_rp.conn is Globals.local_connection |
346 |
reg_rp = dir_rp.append('regfile') |
reg_rp = dir_rp.append('regfile') |
347 |
reg_rp.touch() |
reg_rp.touch() |
348 |
|
|
349 |
s = 'test string---this should end up in resource fork' |
s = 'test string---this should end up in resource fork' |
350 |
try: |
try: |
351 |
fp_write = open(os.path.join(reg_rp.path, 'rsrc'), 'wb') |
fp_write = open(os.path.join(reg_rp.path, '..namedfork', 'rsrc'), 'wb') |
352 |
fp_write.write(s) |
fp_write.write(s) |
353 |
assert not fp_write.close() |
assert not fp_write.close() |
354 |
|
|
355 |
fp_read = open(os.path.join(reg_rp.path, 'rsrc'), 'rb') |
fp_read = open(os.path.join(reg_rp.path, '..namedfork', 'rsrc'), 'rb') |
356 |
s_back = fp_read.read() |
s_back = fp_read.read() |
357 |
assert not fp_read.close() |
assert not fp_read.close() |
358 |
except (OSError, IOError), e: self.resource_forks = 0 |
except (OSError, IOError), e: self.resource_forks = 0 |
370 |
for rp in selection.Select(dir_rp).set_iter(): |
for rp in selection.Select(dir_rp).set_iter(): |
371 |
if rp.isreg(): |
if rp.isreg(): |
372 |
try: |
try: |
373 |
rfork = rp.append('rsrc') |
rfork = rp.append(os.path.join('..namedfork', 'rsrc')) |
374 |
fp = rfork.open('rb') |
fp = rfork.open('rb') |
375 |
fp.read() |
fp.read() |
376 |
assert not fp.close() |
assert not fp.close() |