Skip to content

Commit

Permalink
new file path normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 22, 2014
1 parent 019b81b commit e9bcc47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/src/file_fs/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get(self, connection, file_name):
# creates the target file path from the base path
# and then opens the target file for reading using it
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)
target_file = open(target_file_path, "rb")

# returns the opened target file
Expand All @@ -135,6 +136,7 @@ def delete(self, connection, file_name):
# creates the target file path from the base path
# and removes it from the file system
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)
os.remove(target_file_path)

def put(self, connection, file_path, file_name):
Expand All @@ -150,6 +152,7 @@ def put(self, connection, file_path, file_name):
# retrieves the (base) file name and constructs
# the complete target file path based on it
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)

# retrieves the target directory path and creates
# if if it does not already exists
Expand Down Expand Up @@ -196,6 +199,7 @@ def put_file(self, connection, file, file_name):
# retrieves the (base) file name and constructs
# the complete target file path based on it
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)

# retrieves the target directory path and creates
# if if it does not already exists
Expand Down Expand Up @@ -238,6 +242,7 @@ def put_data(self, connection, data, file_name):
# retrieves the (base) file name and constructs
# the complete target file path based on it
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)

# retrieves the target directory path and creates
# if if it does not already exists
Expand Down Expand Up @@ -288,6 +293,7 @@ def size(self, connection, file_name):
# creates the target file path from the base path
# and uses it to retrieve the size of the file (in bytes)
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)
return os.path.getsize(target_file_path)

def mtime(self, connection, file_name):
Expand All @@ -303,6 +309,7 @@ def mtime(self, connection, file_name):
# creates the target file path from the base path
# and uses it to retrieve the modification timestamp
target_file_path = os.path.join(base_path, file_name)
target_file_path = os.path.normpath(target_file_path)
return os.path.getmtime(target_file_path)

class FsConnection(object):
Expand Down

0 comments on commit e9bcc47

Please sign in to comment.