added copytron filemanager and working on flipper
This commit is contained in:
40
source/copytron.c
Normal file
40
source/copytron.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "copytron.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
copytron_file copytronFileCreate() {
|
||||
copytron_file file = {"", 0};
|
||||
return file;
|
||||
}
|
||||
|
||||
copytron_flips copytronFlipsCreate() {
|
||||
copytron_flips flips;
|
||||
flips.file_count = 0;
|
||||
for(int i = 0; i < 100; i++) {
|
||||
flips.files[i] = copytronFileCreate();
|
||||
}
|
||||
return flips;
|
||||
}
|
||||
|
||||
int copytronAdd(copytron_flips* flips, copytron_file* file) {
|
||||
for(int i = 0; i < 100; i++) {
|
||||
if(flips->files[i].file_path_len == 0) {
|
||||
flips->files[i] = *file;
|
||||
flips->file_count++;
|
||||
}
|
||||
}
|
||||
return flips->file_count;
|
||||
}
|
||||
|
||||
int copytronRemove(copytron_flips* flips, copytron_file* file) {
|
||||
for(int i = 0; i < 100; i++) {
|
||||
if(flips->file_count != 0) {
|
||||
if(strcmp(flips->files[i].path, file->path)) {
|
||||
flips->files[i].path = "";
|
||||
flips->files[i].file_path_len = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user