1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
class StringArrangement
{
public:
char Data[25][1024];
int StringCount;
int Separation(char NewBuffer[1024*3], char SeparationCharacter, bool KeepCharacter)
{
int b = 0;
int a = 0;
int c = 0;
int d = 0;
StringCount = 0;
////Temporary fix for clearing data buffer//
for (int b = 0; a <= 25; a++, b = 0)
{
for (;b <= 32; b++) Data[a][b] = 0;
}
a = 0;
////Temporary fix for clearing data buffer^^//
while (NewBuffer[a] != NULL)
{
for (int b = d; (NewBuffer[a] != SeparationCharacter)&&(NewBuffer[a] != NULL); b++, a++) Data[c][b] = NewBuffer[a];
c++;
if (KeepCharacter == true)
{
Data[c][b] = SeparationCharacter; // Temporary fix for keeping important characters
d = 1;
}
b++;
a++;
StringCount++;
}
return 0;
}
};
class File: public StringArrangement
{
public:
#define MaxFileBuffer 1024*5
int Read(char directory[256], char SeparationCharacter, char FileBuffer[MaxFileBuffer])
{
ifstream File;
File.open(directory);
if (File.is_open() == 1)
{
File.read(FileBuffer, MaxFileBuffer);
File.close();
if (SeparationCharacter != NULL)
{
if (Separation(FileBuffer, SeparationCharacter, 0) == 0) return 0;
}
else return 0;
}
else return 1;
}
int Write(char directory[512], char Data[BufferLength], bool OverWrite, char FileSeparationCharacter[32])
{
int b = 0;
ofstream File;
char FileBuffer[MaxFileBuffer] = "\0";
if (OverWrite == false)
{
Read(directory, NULL, FileBuffer);
while (FileBuffer[b] != NULL) b++;
for (int a = 0; FileSeparationCharacter[a] != NULL; a++, b++) FileBuffer[b] = FileSeparationCharacter[a];
for (int a = 0; Data[a] != NULL; a++, b++) FileBuffer[b] = Data[a];
File.open(directory);
File << FileBuffer;
File.close();
}
else
{
for (int a = 0; Data[a] != NULL; a++, b++) FileBuffer[b] = Data[a];
File.open(directory);
File << FileBuffer;
File.close();
}
return 0;
}
private:
};
|