added copytron filemanager and working on flipper
This commit is contained in:
BIN
.cache/clangd/index/tart.c.3AAACF16E600523C.idx
Normal file
BIN
.cache/clangd/index/tart.c.3AAACF16E600523C.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/tart.h.6945CD9F4BA06FC2.idx
Normal file
BIN
.cache/clangd/index/tart.h.6945CD9F4BA06FC2.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/term.c.F8386F90C4B77402.idx
Normal file
BIN
.cache/clangd/index/term.c.F8386F90C4B77402.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/term.h.66C83CD9EAB6734A.idx
Normal file
BIN
.cache/clangd/index/term.h.66C83CD9EAB6734A.idx
Normal file
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
add_executable(${PROJECT_NAME} main.cpp copytron.c)
|
||||
target_link_libraries(${PROJECT_NAME} TartLib)
|
||||
|
||||
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;
|
||||
}
|
||||
17
source/copytron.h
Normal file
17
source/copytron.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef COPYTRON_H
|
||||
#define COPYTRON_H
|
||||
typedef struct {
|
||||
char path[255];
|
||||
int file_path_len;
|
||||
} copytron_file;
|
||||
|
||||
typedef struct {
|
||||
copytron_file files[100];
|
||||
int file_count;
|
||||
}copytron_flips;
|
||||
|
||||
copytron_file copytronFileCreate();
|
||||
copytron_flips copytronFlipsCreate();
|
||||
int copytronAdd(copytron_flips* flips, copytron_file* file);
|
||||
int copytronRemove(copytron_flips* flips, copytron_file* file);
|
||||
#endif
|
||||
46
source/filemanager.c
Normal file
46
source/filemanager.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "filemanager.h"
|
||||
#include <string.h>
|
||||
|
||||
const char* m_destenation;
|
||||
const char* m_workingDirectory;
|
||||
copytron_flips* m_flips;
|
||||
|
||||
|
||||
void SetCurrentDestenation(const char* des) {
|
||||
m_destenation = des;
|
||||
}
|
||||
|
||||
void SetCurrentWorkingDirectory(const char* workingDir) {
|
||||
m_workingDirectory = workingDir;
|
||||
}
|
||||
|
||||
const char* GetCurrentWorkingDriectory() {
|
||||
return m_workingDirectory;
|
||||
}
|
||||
|
||||
const char* GetCurrentDestenation() {
|
||||
return m_destenation;
|
||||
}
|
||||
|
||||
void SetCopytronFliper(copytron_flips *flips) {
|
||||
m_flips = flips;
|
||||
}
|
||||
|
||||
void AddDirectory(const char * dir) {
|
||||
if(strlen(dir) < 256) {
|
||||
copytron_file file = copytronFileCreate();
|
||||
strcpy(file.path, dir);
|
||||
file.path[strlen(file.path)] = '*';
|
||||
file.file_path_len = strlen(file.path);
|
||||
copytronAdd(m_flips, &file);
|
||||
}
|
||||
}
|
||||
|
||||
void AddFile(const char* dir) {
|
||||
if(strlen(dir) < 256) {
|
||||
copytron_file file = copytronFileCreate();
|
||||
strcpy(file.path, dir);
|
||||
file.file_path_len = strlen(file.path);
|
||||
copytronAdd(m_flips, &file);
|
||||
}
|
||||
}
|
||||
18
source/filemanager.h
Normal file
18
source/filemanager.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FILEMANAGER_H
|
||||
#define FILEMANAGER_H
|
||||
#include "copytron.h"
|
||||
/// sets the current destenation.
|
||||
void SetCurrentDestenation(const char*);
|
||||
const char* GetCurrentDestenation();
|
||||
/// sets the current working directory.
|
||||
void SetCurrentWorkingDirectory(const char*);
|
||||
const char* GetCurrentWorkingDriectory();
|
||||
|
||||
void SetCopytronFliper(copytron_flips* flips);
|
||||
|
||||
/// Adds a directory
|
||||
void AddDirectory(const char*);
|
||||
/// Adds a file
|
||||
void AddFile(const char*);
|
||||
#endif
|
||||
|
||||
1
source/flipper.c
Normal file
1
source/flipper.c
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
12
source/flipper.h
Normal file
12
source/flipper.h
Normal file
@@ -0,0 +1,12 @@
|
||||
typedef struct {
|
||||
char line[255];
|
||||
} line;
|
||||
typedef struct {
|
||||
line lins[50];
|
||||
} buffer;
|
||||
|
||||
void FlipperSetBuffer(const char* path);
|
||||
void FlipperAdd(line);
|
||||
void FlipperRemove(line);
|
||||
void FlipperInDir();
|
||||
void FlipperOutDir();
|
||||
Reference in New Issue
Block a user