Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // recursive copy dir tree to extern disk
- void RecursiveCopyOut(std::string& externPath, Inode& inode, Directory& dir, std::fstream& file, SuperBlock& sb)
- {
- mkdir(externPath.c_str());
- for ( int i = 0; i < dir.HEADER.NUMBER; ++i)
- {
- Inode tmpInode = ReadInode(file, dir.ENTRIES[i].INODE_NUMBER);
- if ( dir.ENTRIES[i].ISFILE == 0 ) // dir
- {
- Directory tmpDir = ReadDirectory( file, tmpInode, sb);
- RecursiveCopyOut( externPath + "\\" + dir.ENTRIES[i].ENTRY_NAME, tmpInode, tmpDir, file ,sb);
- }
- else
- {
- // copy file
- }
- }
- }
- int CopyOutDirectories(std::string& dirToCopy, std::string& parentPath, std::string& externPath)
- {
- std::string targetPath = parentPath + ( parentPath.back() == '/' ? "" : "/") + dirToCopy;
- Directory parentDir;
- Inode parentInode;
- GetDirByName( parentPath, parentDir, parentInode);
- if ( FindEntryInodeNumber(parentDir, dirToCopy.c_str()) == 0)
- {
- return 1;
- }
- Directory dir;
- Inode tocopyInode;
- GetDirByName( targetPath, dir, tocopyInode);
- std::fstream file("testfile.bin", std::fstream::in |
- std::fstream::binary |
- std::fstream::out );
- SuperBlock sb = ReadSuperBlock(file);
- externPath = externPath + ( externPath.back() == '\\' ? "" : "\\") + dirToCopy;
- RecursiveCopyOut(externPath, tocopyInode, dir, file, sb);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement