forked from openkylin/platform_build
Merge "fat16copy: Allow to copy files to an existing directory."
am: 34fd8a168a
Change-Id: Iff82aa2a6d47da741e855038283193c6a928bcb7
This commit is contained in:
commit
bf6b5e8452
|
@ -234,11 +234,16 @@ class fat_dir(object):
|
||||||
data.seek(0)
|
data.seek(0)
|
||||||
data_file.write(data.read())
|
data_file.write(data.read())
|
||||||
|
|
||||||
def new_subdirectory(self, name):
|
def open_subdirectory(self, name):
|
||||||
"""
|
"""
|
||||||
Create a new subdirectory of this directory with the given name.
|
Open a subdirectory of this directory with the given name. If the
|
||||||
|
subdirectory doesn't exist, a new one is created instead.
|
||||||
Returns a fat_dir().
|
Returns a fat_dir().
|
||||||
"""
|
"""
|
||||||
|
for dent in self.dentries:
|
||||||
|
if dent.longname == name:
|
||||||
|
return dent.open_directory()
|
||||||
|
|
||||||
chunk = self.backing.fs.allocate(1)
|
chunk = self.backing.fs.allocate(1)
|
||||||
(shortname, ext) = self.make_short_name(name)
|
(shortname, ext) = self.make_short_name(name)
|
||||||
new_dentry = self.add_dentry(ATTRIBUTE_SUBDIRECTORY, shortname,
|
new_dentry = self.add_dentry(ATTRIBUTE_SUBDIRECTORY, shortname,
|
||||||
|
@ -751,7 +756,7 @@ def add_item(directory, item):
|
||||||
base = os.path.basename(item)
|
base = os.path.basename(item)
|
||||||
if len(base) == 0:
|
if len(base) == 0:
|
||||||
base = os.path.basename(item[:-1])
|
base = os.path.basename(item[:-1])
|
||||||
sub = directory.new_subdirectory(base)
|
sub = directory.open_subdirectory(base)
|
||||||
for next_item in sorted(os.listdir(item)):
|
for next_item in sorted(os.listdir(item)):
|
||||||
add_item(sub, os.path.join(item, next_item))
|
add_item(sub, os.path.join(item, next_item))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue