diff --git a/.gitignore b/.gitignore index 6dcabdd..d2a61d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -./.vscode -./bin \ No newline at end of file +.vscode/ +bin/ +src/tmp* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e99a0f7..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild", - "C_Cpp.default.compileCommands": "/home/thek0tyara/Documents/projects/c/builddir/compile_commands.json" -} \ No newline at end of file diff --git a/bin/main b/bin/main deleted file mode 100755 index 962ad28..0000000 Binary files a/bin/main and /dev/null differ diff --git a/src/tmp1.c b/src/tmp1.c deleted file mode 100644 index 747bd38..0000000 --- a/src/tmp1.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -// Helper to create child paths safely -char* make_child_path(const char* parent, const char* child) { - size_t parent_len = strlen(parent); - size_t child_len = strlen(child); - size_t total = parent_len + child_len + 2; // +2 for '/' and null term - - char* path = malloc(total); - if (!path) return NULL; - - snprintf(path, total, "%s/%s", parent, child); - return path; -} - -// Inside your directory processing loop: -d = (struct linux_dirent64*)(buf + bpos); -bpos += d->d_reclen; - -// Skip . and .. -if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) - continue; - -// Create child path safely -char* child_path = make_child_path(node->path, d->d_name); -if (!child_path) { - perror("malloc failed"); - continue; -} - -// Use stack variable for stat (no allocation) -struct stat file_stat; -if (lstat(child_path, &file_stat) == -1) { // Use lstat to avoid following symlinks - perror("stat failed"); - free(child_path); - continue; -} - -// Determine file type -const char* type = "OTHER"; -long path_size = 0; - -if (S_ISREG(file_stat.st_mode)) { - type = "FILE"; - path_size = file_stat.st_size; -} -else if (S_ISDIR(file_stat.st_mode)) { - type = "DIR"; - // For directory metadata size only (not contents!) - path_size = file_stat.st_blocks * 512; -} -// Add more types (LNK, FIFO, etc) as needed - -printf("%s\t%ld\t%s\n", type, path_size, d->d_name); - -// Cleanup -free(child_path); -*/ \ No newline at end of file diff --git a/src/tmp2.c b/src/tmp2.c deleted file mode 100644 index 68b3d11..0000000 --- a/src/tmp2.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -d = (struct linux_dirent64 *)(buf + bpos); -bpos += d->d_reclen; - -// Skip . and .. entries -if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) - continue; - -// Print filename (no path, no metadata) -// -char *child_path=node->path; -strcat(child_path, "/"); -strcat(child_path, d->d_name); - -struct stat *file_stat=malloc(sizeof(struct stat)); -// bool is_dir; -if (stat(child_path, file_stat) == -1) { - perror("stat failed"); -} - -long path_size = 0; -switch (file_stat->st_mode & S_IFMT) { - case S_IFREG: - path_size=file_stat->st_size; - printf("FILE\t%ld\t%s\n", path_size, child_path); - break; - case S_IFDIR: - path_size=file_stat->st_blocks*512; - printf("DIR\t%ld\t%s/\n", path_size, child_path); - break; - default: - printf("UNKNOWN\t%ld\t%s\n", path_size, child_path); - break; -} -free(child_path); -// free(file_stat); -// free(d); -printf("next...\n"); -*/ \ No newline at end of file