Ticket #2641: vfs_DELETED_folders.patch
File vfs_DELETED_folders.patch, 3.6 KB (added by , 9 years ago) |
---|
-
source/lib/file/vfs/vfs_populate.cpp
1 /* Copyright (c) 201 3Wildfire Games1 /* Copyright (c) 2014 Wildfire Games 2 2 * 3 3 * Permission is hereby granted, free of charge, to any person obtaining 4 4 * a copy of this software and associated documentation files (the … … 78 78 if(name.Extension() == L".DELETED") 79 79 { 80 80 m_directory->RemoveFile(name.Basename()); 81 m_directory->RemoveSubdirectory(name.Basename()); 81 82 if(!(m_realDirectory->Flags() & VFS_MOUNT_KEEP_DELETED)) 82 83 return; 83 84 } … … 100 101 if(name.Extension() == L".DELETED") 101 102 { 102 103 directory->RemoveFile(name.Basename()); 104 // Note: .DELETED files should appear before any files in the 105 // subfolder. Archives that do not follow this should be considered 106 // broken. 107 directory->RemoveSubdirectory(name.Basename()); 103 108 if(!(this_->m_realDirectory->Flags() & VFS_MOUNT_KEEP_DELETED)) 104 109 return; 105 110 } -
source/lib/file/vfs/vfs_tree.cpp
122 122 return &it->second; 123 123 } 124 124 125 void VfsDirectory::RemoveSubdirectory(const VfsPath& name) 126 { 127 VfsSubdirectories::iterator it = m_subdirectories.find(name.string()); 128 if(it == m_subdirectories.end()) 129 return; 130 it->second.Clear(); 131 m_subdirectories.erase(it); 132 } 125 133 126 134 VfsDirectory* VfsDirectory::GetSubdirectory(const VfsPath& name) 127 135 { -
source/lib/file/vfs/vfs_tree.h
1 /* Copyright (c) 201 0Wildfire Games1 /* Copyright (c) 2014 Wildfire Games 2 2 * 3 3 * Permission is hereby granted, free of charge, to any person obtaining 4 4 * a copy of this software and associated documentation files (the … … 106 106 VfsFile* GetFile(const VfsPath& name); 107 107 108 108 /** 109 * remove the given subdirectory (and all files and directories in it) 110 * from the virtual directory. no effect if the subdirectory does not exist. 111 * CAUTION: Invalidates all previously returned pointers of this subdirectory 112 * and everything contained in it. 113 **/ 114 void RemoveSubdirectory(const VfsPath& name); 115 116 /** 109 117 * @return subdirectory with the given name. 110 118 * (note: non-const to allow changes to the subdirectory) 111 119 **/ -
source/ps/ArchiveBuilder.cpp
82 82 83 83 CXeromyces xero; 84 84 85 // Add .DELETED files first, so that we can safely remove folders, 86 // without having to worry about removing files we add. 87 for (size_t i = 0; i < m_Files.size(); ++i) 88 { 89 const VfsPath path = m_Files[i]; 90 if (path.Extension() != L".DELETED") 91 continue; 92 93 Status ret; 94 OsPath realPath; 95 ret = m_VFS->GetRealPath(path, realPath); 96 ENSURE(ret == INFO::OK); 97 debug_printf(L"Adding %ls\n", realPath.string().c_str()); 98 writer->AddFile(realPath, path); 99 } 100 85 101 for (size_t i = 0; i < m_Files.size(); ++i) 86 102 { 87 103 Status ret; 88 104 89 105 const VfsPath path = m_Files[i]; 106 // We already added those, adding them twice might remove files we want to keep. 107 if (path.Extension() == L".DELETED") 108 continue; 109 90 110 OsPath realPath; 91 111 ret = m_VFS->GetRealPath(path, realPath); 92 112 ENSURE(ret == INFO::OK);