DayZ 1.24
Loading...
Searching...
No Matches
PluginFileHandler.c
Go to the documentation of this file.
2{
3 static bool FileDuplicate(string source_name, string dest_name)
4 {
6 }
7
8 static bool FileDelete(string file)
9 {
10 return DeleteFile(file);
11 }
12
13 static void FileRename(string source_name, string dest_name)
14 {
15 FileDuplicate(source_name, dest_name);
16 FileDelete(source_name);
17 }
18
21
23
25 {
26 m_FileContent = new TStringArray;
27 m_LineLimit = -1;
28
29 LoadFile();
30 }
31
33 {
34 ClearFileNoSave();
35 }
36
37 override void OnInit()
38 {
39 super.OnInit();
40 }
41
42 string GetFileName()
43 {
44 return string.Empty;
45 }
46
48 {
49 return string.Empty;
50 }
51
53 {
54 m_FileContent.Clear();
55 }
56
57 bool LoadFile()
58 {
59 ClearFileNoSave();
60
62
63 if (file_index == 0)
64 return false;
65
66 string line_content = "";
68 while (char_count != -1)
69 {
70 m_FileContent.Insert(line_content);
71
73 }
74
76
77 return true;
78 }
79
80 bool SaveFile()
81 {
82 if (m_ReadOnly)
83 return false;
84
87
88 //Log("SaveFile -> Opening File: "+GetFileName());
89
91
92 if (file_index == 0)
93 return false;
94
95 for (int i = 0; i < m_FileContent.Count(); ++i)
96 {
97 //Log("SaveFile -> Writing: "+m_FileContent.Get(i));
98 FPrintln(file_index, m_FileContent.Get(i));
99 }
100
102
103 return true;
104 }
105
107 {
108 return m_ReadOnly;
109 }
110
111 void AddText(string text)
112 {
113 AddNewLineNoSave(text);
114 SaveFile();
115 }
116
118 {
119 if (m_LineLimit > -1)
120 {
121 if (m_LineLimit == 0)
122 return;
123
124 int lines_count = m_FileContent.Count();
125
126 if (lines_count > 0 && lines_count >= m_LineLimit)
127 {
128 int remove_indexes = lines_count - m_LineLimit;
129
130 for (int i = 0; i <= remove_indexes; ++i)
131 m_FileContent.RemoveOrdered(0);
132 }
133 }
134
135 m_FileContent.Insert(text);
136 }
137
139 {
140 return m_FileContent;
141 }
142}
class PluginLocalEnscriptHistory extends PluginLocalHistoryBase GetSubFolderName()
override void OnInit()
TStringArray GetFileContent()
static void FileRename(string source_name, string dest_name)
void PluginFileHandler()
string GetFileName()
void ClearFileNoSave()
void ~PluginFileHandler()
void AddNewLineNoSave(string text)
string GetSubFolderName()
ref TStringArray m_FileContent
void AddText(string text)
static bool FileDelete(string file)
static bool FileDuplicate(string source_name, string dest_name)
override string GetFileName()
array< string > TStringArray
Definition EnScript.c:666
FileMode
Definition EnSystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto native bool MakeDirectory(string name)
Makes a directory.
proto native bool CopyFile(string sourceName, string destName)
copy file. destName must be "$profile:" or "$saves:" location
proto int FGets(FileHandle file, string var)
Get line from file, every next call of this function returns next line.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto bool FileExist(string name)
Check existence of file.
proto native bool DeleteFile(string name)
delete file. Works only on "$profile:" and "$saves:" locations
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.
static const string Empty
Definition EnString.c:7