44 lines
875 B
C
44 lines
875 B
C
#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.
|
|
|
|
}
|