72 lines
1.2 KiB
C++
72 lines
1.2 KiB
C++
/*
|
|
* app.h
|
|
*
|
|
* Created on: Aug 31, 2011
|
|
* Author: Tiberiu
|
|
*/
|
|
|
|
#ifndef APP_H_
|
|
#define APP_H_
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
extern int cmd_create (char** argv, int argc);
|
|
extern int cmd_close (char** argv, int argc);
|
|
extern int cmd_mkdir (char** argv, int argc);
|
|
extern int cmd_cd (char** argv, int argc);
|
|
extern int cmd_add (char** argv, int argc);
|
|
extern int cmd_setflags (char** argv, int argc);
|
|
|
|
|
|
struct Node {
|
|
char Name[256];
|
|
unsigned Flags;
|
|
|
|
vector<Node> Children;
|
|
Node* Parent;
|
|
};
|
|
|
|
struct DirectoryEntry {
|
|
char Name[256];
|
|
unsigned Flags, OwnerId, GroupId, Size;
|
|
struct { unsigned Date; unsigned Time; } TimeCreated, TimeModified, TimeAccessed;
|
|
unsigned Offset;
|
|
};
|
|
|
|
|
|
class RomDisk
|
|
{
|
|
private:
|
|
char OutputFile[256];
|
|
unsigned FlagsDefault;
|
|
|
|
Node Root;
|
|
Node* Current;
|
|
|
|
int IndexOf (char* s);
|
|
|
|
public:
|
|
RomDisk();
|
|
void SetOutFile (char* s);
|
|
void SetFlags (unsigned n);
|
|
int ChangeCurrentDirectory (char* n);
|
|
void AddFile (char* name);
|
|
void AddDirectory (char* name);
|
|
|
|
// WRITE TO FILE
|
|
private:
|
|
void *buffer;
|
|
FILE* file;
|
|
|
|
void prepareBuffer();
|
|
void writeToBuffer(void*, unsigned);
|
|
void writeNode (Node* n);
|
|
long fileSize (char* file);
|
|
long nodeSize (Node* n);
|
|
|
|
public:
|
|
void Close();
|
|
};
|
|
|
|
#endif /* APP_H_ */
|