Compare commits
3 Commits
01fe19866c
...
0a6509310d
Author | SHA1 | Date | |
---|---|---|---|
|
0a6509310d | ||
|
aedfdd1ed5 | ||
|
f2eaeee9ea |
20
backend.c
20
backend.c
@@ -142,6 +142,7 @@ void print_dir(WINDOW *win, unsigned long *line_width, unsigned long *dir_file_c
|
||||
|
||||
unsigned long i = 0;
|
||||
unsigned long j = 0;
|
||||
char is_selected = 0;
|
||||
|
||||
unsigned long offset_front = 2;
|
||||
if (*dir_file_count > 9) {
|
||||
@@ -151,7 +152,14 @@ void print_dir(WINDOW *win, unsigned long *line_width, unsigned long *dir_file_c
|
||||
|
||||
unsigned long offset_back = *line_width - (snprintf(NULL,0,"%ld",dir_content[i].file_size) + 1);
|
||||
unsigned long allowed_width = *line_width+1;
|
||||
wattron(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||
|
||||
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
||||
is_selected = 1;
|
||||
wattron(win, COLOR_PAIR(8));
|
||||
} else {
|
||||
is_selected = 0;
|
||||
wattron(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||
}
|
||||
|
||||
if (dir_content[i].status & FILE_STATUS_HOVER) {
|
||||
wattron(win, A_REVERSE);
|
||||
@@ -163,7 +171,7 @@ void print_dir(WINDOW *win, unsigned long *line_width, unsigned long *dir_file_c
|
||||
mvwaddch(win, i, j, '~');
|
||||
break;
|
||||
}
|
||||
mvwaddch(win, i, offset_front+j, dir_content[i].file_name[j]);
|
||||
mvwaddch(win, i, offset_front+j+is_selected, dir_content[i].file_name[j]);
|
||||
}
|
||||
mvwprintw(win, i, offset_back, "%ld", dir_content[i].file_size);
|
||||
wattroff(win, A_REVERSE);
|
||||
@@ -174,11 +182,15 @@ void print_dir(WINDOW *win, unsigned long *line_width, unsigned long *dir_file_c
|
||||
mvwaddch(win, i, j, '~');
|
||||
break;
|
||||
}
|
||||
mvwaddch(win, i, offset_front+j, dir_content[i].file_name[j]);
|
||||
mvwaddch(win, i, offset_front+j+is_selected, dir_content[i].file_name[j]);
|
||||
}
|
||||
mvwprintw(win, i, offset_back, "%ld", dir_content[i].file_size);
|
||||
}
|
||||
wattroff(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||
if (dir_content[i].status & FILE_STATUS_SELECTED) {
|
||||
wattroff(win, COLOR_PAIR(8));
|
||||
} else {
|
||||
wattroff(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||
}
|
||||
}
|
||||
free(hover_bg);
|
||||
}
|
||||
|
4
config.h
4
config.h
@@ -19,6 +19,8 @@ static mimetype mimetype_default_cmd[] = {
|
||||
static binding key_binding[] = {
|
||||
/*key action */
|
||||
{ "q", quit_program },
|
||||
{ " ", toggle_selection }, /* on hovered file/directory */
|
||||
|
||||
{ "h", move_right }, /* moves one dir up */
|
||||
{ "t", move_down },
|
||||
{ "n", move_up },
|
||||
@@ -26,6 +28,8 @@ static binding key_binding[] = {
|
||||
|
||||
{ "\n", open_with }, /* opens the hovered file with an arbitrary command */
|
||||
{ "r", rename_hovered }, /* renames currently hovered file/directory */
|
||||
{ "d", delete }, /* deletes currently hovered OR selected file/directory
|
||||
* this means that it does not delete the hovered files if files are already selected */
|
||||
|
||||
{ "gg", jump_top },
|
||||
{ "G", jump_bottom },
|
||||
|
@@ -7,9 +7,6 @@
|
||||
#define STATUS_UPDATE_SCREEN_RESIZE 16
|
||||
#define STATUS_UPDATE_SCREEN_RELOAD_FULL 32
|
||||
#define STATUS_USER_ROOT 64
|
||||
#define STATUS_INTERACTIONS_MASK 384
|
||||
#define STATUS_INTERACTIONS_OPEN_WITH 128
|
||||
#define STATUS_INTERACTIONS_RENAME 256
|
||||
|
||||
#define SETTINGS_HAS_COLOR 1
|
||||
|
||||
@@ -24,7 +21,7 @@
|
||||
/*FILE_MODIFIERS_SORT_NATURAL is when bitmask is 0*/
|
||||
|
||||
#define FILE_STATUS_HOVER 1
|
||||
#define FILE_STATUS_SELECTED 2;
|
||||
#define FILE_STATUS_SELECTED 2
|
||||
#define FILE_STATUS_IS_REGULAR_FILE 4
|
||||
#define FILE_STATUS_FILE_OPEN 128 /* only used for file previews */
|
||||
|
||||
|
146
interactions.c
146
interactions.c
@@ -8,37 +8,33 @@
|
||||
#include "config.h"
|
||||
|
||||
|
||||
extern unsigned long selected_file_current;
|
||||
extern unsigned long selected_file_last;
|
||||
|
||||
extern unsigned int file_modifiers;
|
||||
unsigned long selected_file_current;
|
||||
unsigned long selected_file_last;
|
||||
extern pthread_mutex_t mutex_selection;
|
||||
extern pthread_mutex_t mutex_rgt;
|
||||
extern pthread_mutex_t mutex_mid;
|
||||
extern file *mid_content;
|
||||
extern file *lft_content;
|
||||
extern file *rgt_content;
|
||||
extern file file_current;
|
||||
extern file *file_current;
|
||||
|
||||
extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
|
||||
extern WINDOW *win_b;
|
||||
|
||||
extern char *rgt_buffer;
|
||||
extern char *btm_buffer;
|
||||
extern unsigned long mid_file_count;
|
||||
|
||||
extern unsigned int status;
|
||||
void open_with_pass_2();
|
||||
void rename_hovered_pass_2();
|
||||
int read_string(WINDOW *win, int y, int x, char *str);
|
||||
|
||||
void user_interactions(char *input, WINDOW *win_b) {
|
||||
void (*func_ptr)();
|
||||
unsigned long i = 0;
|
||||
if (status & STATUS_INTERACTIONS_MASK) {
|
||||
if (status & STATUS_INTERACTIONS_OPEN_WITH) {
|
||||
open_with_pass_2(win_b);
|
||||
} else if (status & STATUS_INTERACTIONS_RENAME) {
|
||||
rename_hovered_pass_2(win_b);
|
||||
}
|
||||
|
||||
}
|
||||
for (i = 0; i < binding_count; i++) {
|
||||
if (*input == key_binding[i].key[0]) {
|
||||
func_ptr = key_binding[i].func;
|
||||
@@ -49,6 +45,15 @@ void user_interactions(char *input, WINDOW *win_b) {
|
||||
void quit_program(){
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
}
|
||||
void toggle_selection(){
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
mid_content[selected_file_current].status ^= FILE_STATUS_SELECTED;
|
||||
file_current->status ^= FILE_STATUS_SELECTED;
|
||||
status |= (STATUS_UPDATE_SCREEN_MASK);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
}
|
||||
void move_down(){
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
/*capping the maximum file is done inside thread_mid */
|
||||
@@ -69,16 +74,16 @@ void move_right(){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void move_left(){
|
||||
if (file_current.file_type == FILE_TYPE_DIR || file_current.file_type == FILE_TYPE_SYMLINK) {
|
||||
chdir(file_current.file_name);
|
||||
if (file_current->file_type == FILE_TYPE_DIR || file_current->file_type == FILE_TYPE_SYMLINK) {
|
||||
chdir(file_current->file_name);
|
||||
} else {
|
||||
unsigned long i = 0;
|
||||
char *mime = get_mimetype(file_current.file_name);
|
||||
char *mime = get_mimetype(file_current->file_name);
|
||||
for (i = 0; i < mimetype_default_count; i++) {
|
||||
if (strstr(mime, mimetype_default_cmd[i].mimetype)) {
|
||||
|
||||
char *cmd = concat(mimetype_default_cmd[i].command, " ./\"");
|
||||
cmd = concat(cmd, file_current.file_name);
|
||||
cmd = concat(cmd, file_current->file_name);
|
||||
cmd = concat(cmd, "\"");
|
||||
btm_buffer = malloc(strlen(cmd));
|
||||
|
||||
@@ -152,13 +157,15 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
||||
return err;
|
||||
}
|
||||
void open_with(){
|
||||
btm_buffer = concat("open \"", file_current.file_name);
|
||||
btm_buffer = concat("open \"", file_current->file_name);
|
||||
btm_buffer = concat(btm_buffer, "\" with:");
|
||||
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_OPEN_WITH);
|
||||
|
||||
}
|
||||
void open_with_pass_2(WINDOW *win_b){
|
||||
status = STATUS_UPDATE_SCREEN_0;
|
||||
werase(win_b);
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
||||
|
||||
render_pass();
|
||||
unsigned long local_width;
|
||||
unsigned long local_height;
|
||||
getmaxyx(win_b, local_height, local_width);
|
||||
@@ -172,7 +179,7 @@ void open_with_pass_2(WINDOW *win_b){
|
||||
|
||||
if (!err) {
|
||||
char *cmd = concat(str, " ./\"");
|
||||
cmd = concat(cmd, file_current.file_name);
|
||||
cmd = concat(cmd, file_current->file_name);
|
||||
cmd = concat(cmd, "\"");
|
||||
|
||||
system(cmd);
|
||||
@@ -182,7 +189,6 @@ void open_with_pass_2(WINDOW *win_b){
|
||||
|
||||
}
|
||||
|
||||
status &= ~(STATUS_INTERACTIONS_MASK);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||
|
||||
free(str);
|
||||
@@ -190,13 +196,15 @@ void open_with_pass_2(WINDOW *win_b){
|
||||
|
||||
void rename_hovered(){
|
||||
|
||||
btm_buffer = concat("rename \"", file_current.file_name);
|
||||
btm_buffer = concat("rename \"", file_current->file_name);
|
||||
btm_buffer = concat(btm_buffer, "\" to:");
|
||||
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_RENAME);
|
||||
|
||||
}
|
||||
status = STATUS_UPDATE_SCREEN_0;
|
||||
werase(win_b);
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
||||
|
||||
void rename_hovered_pass_2(WINDOW *win_b){
|
||||
render_pass();
|
||||
|
||||
unsigned long local_width;
|
||||
unsigned long local_height;
|
||||
@@ -209,7 +217,7 @@ void rename_hovered_pass_2(WINDOW *win_b){
|
||||
|
||||
|
||||
if (!err) {
|
||||
char *cmd = concat("mv ./\"", file_current.file_name);
|
||||
char *cmd = concat("mv ./\"", file_current->file_name);
|
||||
cmd = concat(cmd, "\" ./\"");
|
||||
cmd = concat(cmd, str);
|
||||
cmd = concat(cmd, "\"");
|
||||
@@ -218,10 +226,88 @@ void rename_hovered_pass_2(WINDOW *win_b){
|
||||
btm_buffer = cmd;
|
||||
}
|
||||
|
||||
status &= ~(STATUS_INTERACTIONS_MASK);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||
|
||||
free(btm_buffer);
|
||||
|
||||
free(str);
|
||||
}
|
||||
|
||||
void delete(){
|
||||
|
||||
unsigned int i = 0;
|
||||
unsigned int hits = 0;
|
||||
char *file_str = " ";
|
||||
for (i = 0; i < mid_file_count; i++) {
|
||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||
file_str = concat(file_str, "\"");
|
||||
file_str = concat(file_str, mid_content[i].file_name);
|
||||
file_str = concat(file_str, "\" ");
|
||||
hits++;
|
||||
}
|
||||
}
|
||||
|
||||
if (hits) {
|
||||
btm_buffer = concat("delete:", file_str);
|
||||
} else {
|
||||
btm_buffer = concat("delete: \"", file_current->file_name);
|
||||
btm_buffer = concat(btm_buffer, "\"");
|
||||
}
|
||||
|
||||
btm_buffer = concat(btm_buffer, "?");
|
||||
btm_buffer = concat(btm_buffer, "\n\n");
|
||||
btm_buffer = concat(btm_buffer, "(y/N)");
|
||||
|
||||
status = STATUS_UPDATE_SCREEN_0;
|
||||
werase(win_b);
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
||||
|
||||
render_pass();
|
||||
|
||||
unsigned long local_width;
|
||||
unsigned long local_height;
|
||||
getmaxyx(win_b, local_height, local_width);
|
||||
|
||||
timeout(-1); /* negative numbers block until enter is pressed */
|
||||
/* TODO(2025-06-22T01:24:30) fix fixed buffer size */
|
||||
char ch = wgetch(win_b);
|
||||
|
||||
if (ch == 'y' || ch == 'Y') {
|
||||
/* the second loop is used to add "./", wich is not being printed" */
|
||||
char *cmd;
|
||||
/* TODO(2025-06-30T02:27:06) IMPORTANT: this really fucks up when the file has a quotation mark in its name */
|
||||
if (hits) {
|
||||
for (i = 0; i < mid_file_count; i++) {
|
||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||
cmd = concat("rm -rf ./\"", mid_content[i].file_name);
|
||||
cmd = concat(cmd, "\"");
|
||||
system(cmd);
|
||||
}
|
||||
}
|
||||
free(btm_buffer);
|
||||
btm_buffer = concat("deleted: ", file_str);
|
||||
} else {
|
||||
free(btm_buffer);
|
||||
btm_buffer = concat("deleted: \"", file_current->file_name);
|
||||
btm_buffer = concat(btm_buffer, "\"");
|
||||
cmd = concat("rm -rf ./\"", file_current->file_name);
|
||||
cmd = concat(cmd, "\"");
|
||||
system(cmd);
|
||||
|
||||
}
|
||||
/*system(cmd);*/
|
||||
free(cmd);
|
||||
|
||||
} else {
|
||||
free(btm_buffer);
|
||||
btm_buffer = "cancled deletion";
|
||||
}
|
||||
|
||||
timeout(10);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||
|
||||
if (hits) {
|
||||
free(file_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
void user_interactions(char *input, WINDOW *win_b);
|
||||
void quit_program();
|
||||
void toggle_selection();
|
||||
void move_right();
|
||||
void move_up();
|
||||
void move_down();
|
||||
@@ -17,3 +18,4 @@ void jump_top();
|
||||
void toggle_hidden_files();
|
||||
void open_with();
|
||||
void rename_hovered();
|
||||
void delete();
|
||||
|
41
main.c
41
main.c
@@ -20,8 +20,14 @@ unsigned int status;
|
||||
unsigned int timeout_time = 0;
|
||||
char input = 0;
|
||||
|
||||
WINDOW *win_t;
|
||||
WINDOW *win_b;
|
||||
WINDOW *win_l;
|
||||
WINDOW *win_m;
|
||||
WINDOW *win_r;
|
||||
|
||||
void render_pass(WINDOW *wint, WINDOW *winb, WINDOW *winl, WINDOW *winm, WINDOW *winr);
|
||||
|
||||
void render_pass();
|
||||
void init();
|
||||
|
||||
|
||||
@@ -30,11 +36,16 @@ int main(){
|
||||
init();
|
||||
|
||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||
WINDOW *win_t = newwin(1, terminal_width, 0, 0);
|
||||
WINDOW *win_b = newwin(1, terminal_width, terminal_height-1, 0);
|
||||
WINDOW *win_l = newwin(terminal_height-2, terminal_width/8, 1, 0);
|
||||
WINDOW *win_m = newwin(terminal_height-2, terminal_width/3, 1, (terminal_width/8));
|
||||
WINDOW *win_r = newwin(terminal_height-2, terminal_width/3, 1, ((terminal_width/2)));
|
||||
WINDOW *wint = newwin(1, terminal_width, 0, 0);
|
||||
WINDOW *winb = newwin(1, terminal_width, terminal_height-1, 0);
|
||||
WINDOW *winl = newwin(terminal_height-2, terminal_width/8, 1, 0);
|
||||
WINDOW *winm = newwin(terminal_height-2, terminal_width/3, 1, (terminal_width/8));
|
||||
WINDOW *winr = newwin(terminal_height-2, terminal_width/3, 1, ((terminal_width/2)));
|
||||
win_t = wint;
|
||||
win_b = winb;
|
||||
win_r = winr;
|
||||
win_m = winm;
|
||||
win_l = winl;
|
||||
|
||||
pthread_t thread_b;
|
||||
pthread_t thread_t;
|
||||
@@ -80,7 +91,7 @@ int main(){
|
||||
timeout(timeout_time); /* blocking timeout of getch() */
|
||||
|
||||
|
||||
render_pass(win_t, win_b, win_l, win_m, win_r);
|
||||
render_pass();
|
||||
|
||||
}
|
||||
/*
|
||||
@@ -106,9 +117,9 @@ int main(){
|
||||
}
|
||||
|
||||
|
||||
void render_pass(WINDOW *win_t, WINDOW *win_b, WINDOW *win_l, WINDOW *win_m, WINDOW *win_r){
|
||||
void render_pass(){
|
||||
|
||||
if (status & (STATUS_UPDATE_SCREEN_RESIZE | STATUS_INTERACTIONS_MASK)) {
|
||||
if (status & STATUS_UPDATE_SCREEN_RESIZE) {
|
||||
if (status & STATUS_UPDATE_SCREEN_RELOAD_FULL) {
|
||||
clear();
|
||||
status &= ~STATUS_UPDATE_SCREEN_RELOAD_FULL;
|
||||
@@ -126,22 +137,14 @@ void render_pass(WINDOW *win_t, WINDOW *win_b, WINDOW *win_l, WINDOW *win_m, WIN
|
||||
wresize(win_l, terminal_height-2, terminal_width/8);
|
||||
wresize(win_m, terminal_height-2, (terminal_width/2)-(terminal_width/8));
|
||||
wresize(win_r, terminal_height-2, terminal_width/2);
|
||||
if(status & STATUS_INTERACTIONS_MASK) {
|
||||
wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/
|
||||
} else {
|
||||
wresize(win_b, 1, terminal_width);
|
||||
}
|
||||
wresize(win_b, 1, terminal_width);
|
||||
|
||||
|
||||
mvwin(win_t, 0, 0);
|
||||
mvwin(win_l, 1, 0);
|
||||
mvwin(win_m, 1, (terminal_width/8));
|
||||
mvwin(win_r, 1, ((terminal_width/2)));
|
||||
if(status & STATUS_INTERACTIONS_MASK) {
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
} else {
|
||||
mvwin(win_b, terminal_height-1, 0);
|
||||
}
|
||||
mvwin(win_b, terminal_height-1, 0);
|
||||
|
||||
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
|
51
threading.c
51
threading.c
@@ -23,7 +23,7 @@ file *lft_content;
|
||||
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
|
||||
char *btm_buffer;
|
||||
|
||||
file file_current;
|
||||
file *file_current;
|
||||
|
||||
char *top_content; /* current path */
|
||||
|
||||
@@ -34,9 +34,9 @@ unsigned long top_width;
|
||||
|
||||
|
||||
|
||||
unsigned long selected_file_current=0;
|
||||
unsigned long selected_file_last=0;
|
||||
extern unsigned int status;
|
||||
extern unsigned long selected_file_current;
|
||||
extern unsigned long selected_file_last;
|
||||
|
||||
void *thread_rgt(void *data);
|
||||
|
||||
@@ -63,20 +63,23 @@ void *thread_mid(void *data){
|
||||
|
||||
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
while(1) { /* this useless while loop exists for the singular purpose of making valgrind happy */
|
||||
if (selected_file_current >= mid_file_count) {
|
||||
selected_file_current = mid_file_count-1;
|
||||
}
|
||||
mid_content[selected_file_current].status = FILE_STATUS_HOVER;
|
||||
if (selected_file_current != selected_file_last) {
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
}
|
||||
selected_file_last = selected_file_current;
|
||||
} else {
|
||||
mid_content[selected_file_current].status |= FILE_STATUS_HOVER;
|
||||
if (selected_file_current != selected_file_last) {
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
}
|
||||
selected_file_last = selected_file_current;
|
||||
|
||||
file_current.file_name = malloc(mid_content[selected_file_current].file_name_width + 1);
|
||||
strcpy(file_current.file_name, mid_content[selected_file_current].file_name);
|
||||
file_current.file_name_width = mid_content[selected_file_current].file_name_width;
|
||||
file_current.file_size = mid_content[selected_file_current].file_size;
|
||||
file_current.file_type = mid_content[selected_file_current].file_type;
|
||||
file_current->file_name = mid_content[selected_file_current].file_name;
|
||||
file_current->file_name_width = mid_content[selected_file_current].file_name_width;
|
||||
file_current->file_size = mid_content[selected_file_current].file_size;
|
||||
file_current->file_type = mid_content[selected_file_current].file_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
}
|
||||
@@ -119,11 +122,11 @@ void *thread_rgt(void *data){
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
free(rgt_content);
|
||||
rgt_content = malloc(sizeof(file));
|
||||
rgt_content[0].file_name = malloc(file_current.file_name_width + 1);
|
||||
strcpy(rgt_content[0].file_name, file_current.file_name);
|
||||
rgt_content[0].file_name_width = file_current.file_name_width;
|
||||
rgt_content[0].file_size = file_current.file_size;
|
||||
rgt_content[0].file_type = file_current.file_type;
|
||||
rgt_content[0].file_name = malloc(file_current->file_name_width + 1);
|
||||
strcpy(rgt_content[0].file_name, file_current->file_name);
|
||||
rgt_content[0].file_name_width = file_current->file_name_width;
|
||||
rgt_content[0].file_size = file_current->file_size;
|
||||
rgt_content[0].file_type = file_current->file_type;
|
||||
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
@@ -183,10 +186,12 @@ void threading_init(){
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
btm_buffer = malloc(sizeof(char));
|
||||
|
||||
file_current.file_type = 0;
|
||||
file_current.file_size = 1;
|
||||
file_current.file_name_width = 1;
|
||||
file_current.file_name = "a";
|
||||
file_current = malloc(sizeof(file));
|
||||
file_current->file_type = 0;
|
||||
file_current->file_size = 1;
|
||||
file_current->file_name_width = 1;
|
||||
file_current->file_name = malloc(sizeof("a"));
|
||||
strcpy(file_current->file_name, "a");
|
||||
|
||||
pthread_mutex_init(&mutex_top, NULL);
|
||||
pthread_mutex_init(&mutex_mid, NULL);
|
||||
|
Reference in New Issue
Block a user