starting to add flipper
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
add_executable(${PROJECT_NAME} main.cpp copytron.c)
|
||||
add_executable(${PROJECT_NAME} main.cpp copytron.c flipper.c)
|
||||
target_link_libraries(${PROJECT_NAME} TartLib)
|
||||
|
||||
@@ -30,7 +30,7 @@ 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].path = 0x00;
|
||||
flips->files[i].file_path_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1 +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.
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#ifndef FLIPPER_H
|
||||
#define FLIPPER_H
|
||||
|
||||
typedef struct {
|
||||
char line[255];
|
||||
} line;
|
||||
} flipper_line;
|
||||
typedef struct {
|
||||
line lins[50];
|
||||
} buffer;
|
||||
flipper_line lins[50];
|
||||
} flipper_buffer;
|
||||
|
||||
void FlipperSetBuffer(const char* path);
|
||||
void FlipperAdd(line);
|
||||
void FlipperRemove(line);
|
||||
void FlipperInDir();
|
||||
void FlipperOutDir();
|
||||
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