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)
|
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++) {
|
for(int i = 0; i < 100; i++) {
|
||||||
if(flips->file_count != 0) {
|
if(flips->file_count != 0) {
|
||||||
if(strcmp(flips->files[i].path, file->path)) {
|
if(strcmp(flips->files[i].path, file->path)) {
|
||||||
flips->files[i].path = "";
|
//flips->files[i].path = 0x00;
|
||||||
flips->files[i].file_path_len = 0;
|
flips->files[i].file_path_len = 0;
|
||||||
return 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 {
|
typedef struct {
|
||||||
char line[255];
|
char line[255];
|
||||||
} line;
|
} flipper_line;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
line lins[50];
|
flipper_line lins[50];
|
||||||
} buffer;
|
} flipper_buffer;
|
||||||
|
|
||||||
void FlipperSetBuffer(const char* path);
|
void FlipperSetBuffer(const char* path);
|
||||||
void FlipperAdd(line);
|
void FlipperAdd(flipper_line);
|
||||||
void FlipperRemove(line);
|
void FlipperRemove(flipper_line);
|
||||||
void FlipperInDir();
|
void FlipperWorkingDir(const char* path);
|
||||||
void FlipperOutDir();
|
void FlipperOutputDir(const char* path);
|
||||||
|
|
||||||
|
#endif // !FLIPPER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user