extract common code
Merge pull request #1570 from owncloud/refactor_filelist_addFile_addDir

extract common code