DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginFileHandler.c
См. документацию.
2{
3 static bool FileDuplicate(string source_name, string dest_name)
4 {
5 return CopyFile(source_name, dest_name);
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 {
27 m_LineLimit = -1;
28
29 LoadFile();
30 }
31
33 {
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 {
60
61 FileHandle file_index = OpenFile(GetFileName(), FileMode.READ);
62
63 if ( file_index == 0 )
64 {
65 return false;
66 }
67
68 string line_content = "";
69 int char_count = FGets( file_index, line_content );
70 while ( char_count != -1 )
71 {
72 m_FileContent.Insert(line_content);
73
74 char_count = FGets( file_index, line_content );
75 }
76
77 CloseFile(file_index);
78
79 return true;
80 }
81
82 bool SaveFile()
83 {
84 if ( m_ReadOnly )
85 {
86 return false;
87 }
88
90 {
92 }
93
94 //Log("SaveFile -> Opening File: "+GetFileName());
95
96 FileHandle file_index = OpenFile(GetFileName(), FileMode.WRITE);
97
98 if ( file_index == 0 )
99 {
100 return false;
101 }
102
103 for ( int i = 0; i < m_FileContent.Count(); ++i)
104 {
105 //Log("SaveFile -> Writing: "+m_FileContent.Get(i));
106 FPrintln(file_index, m_FileContent.Get(i));
107 }
108
109 CloseFile(file_index);
110
111 return true;
112 }
113
115 {
116 return m_ReadOnly;
117 }
118
119 void AddText(string text)
120 {
121 AddNewLineNoSave(text);
122 SaveFile();
123 }
124
125 void AddNewLineNoSave(string text)
126 {
127 if ( m_LineLimit > -1 )
128 {
129 if ( m_LineLimit == 0 )
130 {
131 return;
132 }
133
134 int lines_count = m_FileContent.Count();
135
136 if ( lines_count > 0 && lines_count >= m_LineLimit )
137 {
138 int remove_indexes = lines_count - m_LineLimit;
139
140 for ( int i = 0; i <= remove_indexes; ++i )
141 {
142 m_FileContent.RemoveOrdered(0);
143 }
144 }
145 }
146
147 m_FileContent.Insert(text);
148 }
149
151 {
152 return m_FileContent;
153 }
154}
class PluginLocalEnscriptHistory extends PluginLocalHistoryBase GetSubFolderName()
Определения PluginLocalEnscriptHistory.c:20
override void OnInit()
Определения PluginFileHandler.c:37
int m_LineLimit
Определения PluginFileHandler.c:20
bool SaveFile()
Определения PluginFileHandler.c:82
bool IsReadOnly()
Определения PluginFileHandler.c:114
TStringArray GetFileContent()
Определения PluginFileHandler.c:150
bool m_ReadOnly
Определения PluginFileHandler.c:19
bool LoadFile()
Определения PluginFileHandler.c:57
static void FileRename(string source_name, string dest_name)
Определения PluginFileHandler.c:13
void PluginFileHandler()
Определения PluginFileHandler.c:24
string GetFileName()
Определения PluginFileHandler.c:42
void ClearFileNoSave()
Определения PluginFileHandler.c:52
void ~PluginFileHandler()
Определения PluginFileHandler.c:32
void AddNewLineNoSave(string text)
Определения PluginFileHandler.c:125
string GetSubFolderName()
Определения PluginFileHandler.c:47
ref TStringArray m_FileContent
Определения PluginFileHandler.c:22
void AddText(string text)
Определения PluginFileHandler.c:119
static bool FileDelete(string file)
Определения PluginFileHandler.c:8
static bool FileDuplicate(string source_name, string dest_name)
Определения PluginFileHandler.c:3
Определения PluginBase.c:2
override string GetFileName()
Определения PluginConfigHandler.c:17
array< string > TStringArray
Определения EnScript.c:685
FileMode
Определения 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.
int[] FileHandle
Определения EnSystem.c:390
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
Определения EnString.c:7