Compare commits
2 Commits
master
...
prerelease
| Author | SHA1 | Date | |
|---|---|---|---|
| 439ebe7279 | |||
| 2a13827e87 |
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 flipper.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 = 0x00;
|
||||
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
|
||||
|
||||
43
source/flipper.c
Normal file
43
source/flipper.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "flipper.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char* m_outputPath;
|
||||
const char* m_workingPath;
|
||||
flipper_buffer m_outputBuffer;
|
||||
flipper_buffer m_workingBuffer;
|
||||
|
||||
void FlipperWorkingDir(const char* path) {
|
||||
m_workingPath = path;
|
||||
}
|
||||
|
||||
void FlipperOutputDir(const char* path) {
|
||||
m_outputPath = path;
|
||||
}
|
||||
|
||||
void _UpdateBuffer(flipper_buffer* buffer, const char* path) {
|
||||
char command_buffer[1024];
|
||||
int path_size = strlen(path);
|
||||
char* command;
|
||||
memset(command, (path_size + 6) * sizeof(char), sizeof(char));
|
||||
|
||||
strcpy(command, "ls ");
|
||||
strcat(command, path);
|
||||
strcat(command, " -a");
|
||||
|
||||
FILE* f = popen(command,"r");
|
||||
fseek(f,0L,SEEK_END);
|
||||
long sz = ftell(f);
|
||||
fseek(f,0L,SEEK_SET);
|
||||
|
||||
|
||||
fread(command_buffer, sz,0,f);
|
||||
|
||||
fclose(f);
|
||||
|
||||
free(command);
|
||||
|
||||
// do stuff with the command buffer.
|
||||
|
||||
}
|
||||
17
source/flipper.h
Normal file
17
source/flipper.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef FLIPPER_H
|
||||
#define FLIPPER_H
|
||||
|
||||
typedef struct {
|
||||
char line[255];
|
||||
} flipper_line;
|
||||
typedef struct {
|
||||
flipper_line lins[50];
|
||||
} flipper_buffer;
|
||||
|
||||
void FlipperSetBuffer(const char* path);
|
||||
void FlipperAdd(flipper_line);
|
||||
void FlipperRemove(flipper_line);
|
||||
void FlipperWorkingDir(const char* path);
|
||||
void FlipperOutputDir(const char* path);
|
||||
|
||||
#endif // !FLIPPER_H
|
||||
Reference in New Issue
Block a user