Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSInterface_VFS.h
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 // JSInterface_VFS.h
19 //
20 // The JavaScript wrapper around useful snippets of the VFS
21 
22 #ifndef INCLUDED_JSI_VFS
23 #define INCLUDED_JSI_VFS
24 
26 
27 // these are registered in ScriptGlue.cpp, hence the need for a header.
28 
29 namespace JSI_VFS
30 {
31  // Return an array of pathname strings, one for each matching entry in the
32  // specified directory.
33  //
34  // pathnames = buildDirEntList(start_path [, filter_string [, recursive ] ]);
35  // directory: VFS path
36  // filter_string: see match_wildcard; "" matches everything.
37  // recurse: should subdirectories be included in the search? default false.
38  //
39  // note: full pathnames of each file/subdirectory are returned,
40  // ready for use as a "filename" for the other functions.
41  JSBool BuildDirEntList(JSContext* cx, uintN argc, jsval* vp);
42 
43  // Return time [seconds since 1970] of the last modification to the specified file.
44  //
45  // mtime = getFileMTime(filename);
46  // filename: VFS filename (may include path)
47  JSBool GetFileMTime(JSContext* cx, uintN argc, jsval* vp);
48 
49  // Return current size of file.
50  //
51  // size = getFileSize(filename);
52  // filename: VFS filename (may include path)
53  JSBool GetFileSize(JSContext* cx, uintN argc, jsval* vp);
54 
55  // Return file contents in a string.
56  //
57  // contents = readFile(filename);
58  // filename: VFS filename (may include path)
59  JSBool ReadFile(JSContext* cx, uintN argc, jsval* vp);
60 
61  // Return file contents as an array of lines.
62  //
63  // lines = readFileLines(filename);
64  // filename: VFS filename (may include path)
65  JSBool ReadFileLines(JSContext* cx, uintN argc, jsval* vp);
66 
67  // Abort the current archive build operation (no-op if not currently active).
68  //
69  // archiveBuilderCancel();
70  JSBool ArchiveBuilderCancel(JSContext* cx, uintN argc, jsval* vp);
71 }
72 
73 #endif
JSBool GetFileMTime(JSContext *cx, uintN argc, jsval *vp)
JSBool ReadFile(JSContext *cx, uintN argc, jsval *vp)
JSBool BuildDirEntList(JSContext *cx, uintN argc, jsval *vp)
JSBool ReadFileLines(JSContext *cx, uintN argc, jsval *vp)
JSBool ArchiveBuilderCancel(JSContext *cx, uintN argc, jsval *vp)
JSBool GetFileSize(JSContext *cx, uintN argc, jsval *vp)