Skip to content

Commit

Permalink
adding previously uncommitted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nklose committed Sep 12, 2017
1 parent f6f7f70 commit e15e919
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
20 changes: 18 additions & 2 deletions src/CommandController.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,27 @@ def prompt(user):
gc.error('The object you entered doesn\'t exist here.')
else:
# show command usage
gc.msg('Enter rn [object] [newname] to rename a file or folder.')
gc.msg('Enter rn [object] [newname] to rename a file or directory.')

# copies an object
elif base_cmd in ['cp', 'copy']:
pass
if len(cmds) > 2:
obj_name = cmds[1]
new_name = cmds[2]

# check if object is a file
file = File(obj_name, directory)
file.lookup()
if file.exists:
newfile = File(new_name, directory)
newfile.lookup()
if newfile.exists:
gc.error('A file already exists here with the name you specified.')
else:
newfile.copy(file)
else:
# show command usage
gc.msg('Enter cp [object] [newname] to copy a file or directory.')

# show disk info
elif base_cmd == 'disk':
Expand Down
21 changes: 16 additions & 5 deletions src/File.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,22 @@ def save(self):
def get_content(self):
return self.content

def rename(self, new_name):
pass

def copy(self, dest_id):
pass
# copies a source file's properties to this file
def copy(self, source):
self.parent = source.parent
self.owner_id = source.id
self.content = source.content
self.type = source.type
self.level = source.level
self.size = source.size
self.creation_time = source.creation_time
self.modified_time = source.modified_time
self.category = source.category
self.comment = source.comment
self.memory = source.memory
self.is_live = source.is_live
self.save()
self.exists = True

# permanently delete this file
def delete(self):
Expand Down

0 comments on commit e15e919

Please sign in to comment.