From b1f4d2bedf9af7470e43cce69d19f30f8918bd31 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 2 Aug 2022 18:46:32 +0200 Subject: [PATCH] Update README --- .gitignore | 3 ++- README.md | 8 +++++--- banner | 11 +++++------ src/copy_functions.cpp | 25 +++++++++++++++---------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 6d54ce1..7a6e607 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ tests/ exec/ .vscode/ -releases/ \ No newline at end of file +releases/ +data/ \ No newline at end of file diff --git a/README.md b/README.md index 32870a8..93f3911 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # File splitter by size -This script will divide in folders a selected set data by a given size. Very useful for perform backups in a limited drives. +This software helps making backup copies when the backup storage drive is not enough for whole copy, like USB sticks. -## How to use -The main use of this program is for perfom backups to others machines using drives that doesn't have enough space to storage all the data, so you will have manually select the files and directories that suit into the drive and repeat this until all data is copied. This program split the files and directories in diferent folders in a logical way, that is the folders structure will not change, the program just read all the files and selected until the maximum size indicated by the user. Also it can perform the copies. +## How it works +The main use is to move data to other computers using a external drive that can't storage the whole backup itself. This software will automatically fill the external drive with the data until the maximum storage limit. Once the first copy is done, you can use other external drive to continue with the copy, or use the same external drive when it have enough space. The copy will continue from the last copied file, even if you close the software. + +The information of the copy process is storage in a file in the `data` folder. Each copy will have his own file, with an identifier generated with a md5 hash from the source folder copy. This file will contain a bitmap of all files listed of the source folder, where 0 value means not copied and 1 value means copied. ### Win32 API This program only works for Windows OS because it's use the [Win32 API](https://docs.microsoft.com/en-us/windows/win32/api/) for some funcionalities. Maybe in the future I will code it for Linux systems. diff --git a/banner b/banner index adbe929..e07cc89 100644 --- a/banner +++ b/banner @@ -1,8 +1,7 @@ - ______ _____ ____ _____ - | ____| / ____| | _ \ / ____| - | |__ | (___ | |_) | | (___ - | __| \___ \ | _ < \___ \ - | | ____) | | |_) | ____) | - |_| |_____/ |____/ |_____/ + ___________ ____ _____ + / ____/ ___// __ ) ___/ + / /_ \__ \/ __ \__ \ + / __/ ___/ / /_/ /__/ / + /_/ /____/_____/____/ https://github.com/alb3rtov/file-splitter-by-size diff --git a/src/copy_functions.cpp b/src/copy_functions.cpp index 4cef898..9e643d6 100644 --- a/src/copy_functions.cpp +++ b/src/copy_functions.cpp @@ -182,7 +182,7 @@ long long int generate_current_vector_files(std::vector ¤t_fi i++; } - std::ofstream file(md5_copy_id); + std::ofstream file("data/" + md5_copy_id); for (int k = 0; k < bitmap_files.size(); k++ ) { file << bitmap_files[k]; } @@ -418,15 +418,23 @@ void make_copy() md5_copy_id = md5(directory_path); size = list_all_files(directory_path, files, files_sizes, directories); - if (!is_path_exist(md5_copy_id)) { - std::ofstream file(md5_copy_id); + if (!CreateDirectoryA("data", 0)) + { + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + std::cout << "Error: " << GetLastError() << std::endl; + } + } + + if (!is_path_exist("data/" + md5_copy_id)) { + std::ofstream file("data/" + md5_copy_id); for (int i = 0; i < bitmap_files.size(); i++ ) { file << bitmap_files[i]; } file.close(); } else { - std::ifstream read_file(md5_copy_id); + std::ifstream read_file("data/" + md5_copy_id); std::string read_bitmap; std::getline(read_file, read_bitmap); @@ -495,10 +503,6 @@ void make_copy() flag = true; } - //if (!flag) { - - //} - pause(total_real_size, mb, total_size, flag, elapsed); } else @@ -521,8 +525,9 @@ void make_copy() } } - if (is_path_exist(md5_copy_id)) { - remove(md5_copy_id.c_str()); + if (is_path_exist("data/" + md5_copy_id)) { + std::string path_to_delete = "data/" + md5_copy_id; + remove(path_to_delete.c_str()); } } else