Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
alb3rtov committed Aug 2, 2022
1 parent 452951a commit b1f4d2b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
tests/
exec/
.vscode/
releases/
releases/
data/
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 5 additions & 6 deletions banner
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
______ _____ ____ _____
| ____| / ____| | _ \ / ____|
| |__ | (___ | |_) | | (___
| __| \___ \ | _ < \___ \
| | ____) | | |_) | ____) |
|_| |_____/ |____/ |_____/
___________ ____ _____
/ ____/ ___// __ ) ___/
/ /_ \__ \/ __ \__ \
/ __/ ___/ / /_/ /__/ /
/_/ /____/_____/____/

https://github.com/alb3rtov/file-splitter-by-size
25 changes: 15 additions & 10 deletions src/copy_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ long long int generate_current_vector_files(std::vector<std::string> &current_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];
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -495,10 +503,6 @@ void make_copy()
flag = true;
}

//if (!flag) {

//}

pause(total_real_size, mb, total_size, flag, elapsed);
}
else
Expand All @@ -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
Expand Down

0 comments on commit b1f4d2b

Please sign in to comment.