PageRenderTime 64ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/std/ext_std_file.h

https://gitlab.com/0072016/0072016-PHP.LLC
C Header | 350 lines | 317 code | 9 blank | 24 comment | 0 complexity | 6388d7045caf753d65deb4bda7927f4b MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | HipHop for PHP |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2010-2015 Facebook, Inc. (http://www.facebook.com) |
  6. | Copyright (c) 1997-2010 The PHP Group |
  7. +----------------------------------------------------------------------+
  8. | This source file is subject to version 3.01 of the PHP license, |
  9. | that is bundled with this package in the file LICENSE, and is |
  10. | available through the world-wide-web at the following url: |
  11. | http://www.php.net/license/3_01.txt |
  12. | If you did not receive a copy of the PHP license and are unable to |
  13. | obtain it through the world-wide-web, please send a note to |
  14. | license@php.net so we can mail you a copy immediately. |
  15. +----------------------------------------------------------------------+
  16. */
  17. #ifndef incl_HPHP_EXT_FILE_H_
  18. #define incl_HPHP_EXT_FILE_H_
  19. #include "hphp/runtime/ext/extension.h"
  20. #include "hphp/runtime/ext/stream/ext_stream.h"
  21. // To get the values of the SEEK constants
  22. #include <stdio.h>
  23. #undef basename
  24. namespace HPHP {
  25. ///////////////////////////////////////////////////////////////////////////////
  26. // constants
  27. #define k_STDIN (BuiltinFiles::GetSTDIN())
  28. #define k_STDOUT (BuiltinFiles::GetSTDOUT())
  29. #define k_STDERR (BuiltinFiles::GetSTDERR())
  30. const StaticString s_DIRECTORY_SEPARATOR("/");
  31. const int64_t k_FILE_USE_INCLUDE_PATH = 1;
  32. const int64_t k_FILE_IGNORE_NEW_LINES = 2;
  33. const int64_t k_FILE_SKIP_EMPTY_LINES = 4;
  34. const int64_t k_FILE_APPEND = 8;
  35. const int64_t k_FILE_NO_DEFAULT_CONTEXT = 16;
  36. const int64_t k_FILE_TEXT = 0;
  37. const int64_t k_FILE_BINARY = 0;
  38. const int64_t k_FNM_NOESCAPE = 2;
  39. const int64_t k_FNM_CASEFOLD = 16;
  40. const int64_t k_FNM_PERIOD = 4;
  41. const int64_t k_FNM_PATHNAME = 1;
  42. const int64_t k_GLOB_AVAILABLE_FLAGS = 9303;
  43. const int64_t k_GLOB_BRACE = 1024;
  44. const int64_t k_GLOB_ERR = 1;
  45. const int64_t k_GLOB_MARK = 2;
  46. const int64_t k_GLOB_NOCHECK = 16;
  47. const int64_t k_GLOB_NOESCAPE = 64;
  48. const int64_t k_GLOB_NOSORT = 4;
  49. const int64_t k_GLOB_ONLYDIR = 8192;
  50. const int64_t k_LOCK_SH = 1;
  51. const int64_t k_LOCK_EX = 2;
  52. const int64_t k_LOCK_UN = 3;
  53. const int64_t k_LOCK_NB = 4;
  54. const StaticString s_PATH_SEPARATOR(":");
  55. const int64_t k_SCANDIR_SORT_ASCENDING = 0;
  56. const int64_t k_SCANDIR_SORT_DESCENDING = 1;
  57. const int64_t k_SCANDIR_SORT_NONE = 2;
  58. // These are defined in stdio.h
  59. const int64_t k_SEEK_SET = SEEK_SET;
  60. const int64_t k_SEEK_CUR = SEEK_CUR;
  61. const int64_t k_SEEK_END = SEEK_END;
  62. // This can probably be removed when we register this constant via HNI
  63. // in the appropriate extension or global constants file
  64. extern const int64_t k_INI_SCANNER_NORMAL;
  65. ///////////////////////////////////////////////////////////////////////////////
  66. // file handle based file operations
  67. Variant HHVM_FUNCTION(fopen,
  68. const String& filename,
  69. const String& mode,
  70. bool use_include_path = false,
  71. const Variant& context = uninit_null());
  72. Variant HHVM_FUNCTION(popen,
  73. const String& command,
  74. const String& mode);
  75. bool HHVM_FUNCTION(fclose,
  76. const Resource& handle);
  77. Variant HHVM_FUNCTION(pclose,
  78. const Variant& handle);
  79. Variant HHVM_FUNCTION(fseek,
  80. const Resource& handle,
  81. int64_t offset,
  82. int64_t whence = k_SEEK_SET);
  83. bool HHVM_FUNCTION(rewind,
  84. const Resource& handle);
  85. Variant HHVM_FUNCTION(ftell,
  86. const Resource& handle);
  87. bool HHVM_FUNCTION(feof,
  88. const Resource& handle);
  89. Variant HHVM_FUNCTION(fstat,
  90. const Resource& handle);
  91. Variant HHVM_FUNCTION(fread,
  92. const Resource& handle,
  93. int64_t length);
  94. Variant HHVM_FUNCTION(fgetc,
  95. const Resource& handle);
  96. Variant HHVM_FUNCTION(fgets,
  97. const Resource& handle,
  98. int64_t length = 0);
  99. Variant HHVM_FUNCTION(fgetss,
  100. const Resource& handle,
  101. int64_t length = 0,
  102. const String& allowable_tags = null_string);
  103. TypedValue* HHVM_FN(fscanf)(ActRec* ar);
  104. Variant HHVM_FUNCTION(fpassthru,
  105. const Resource& handle);
  106. Variant HHVM_FUNCTION(fwrite,
  107. const Resource& handle,
  108. const String& data,
  109. int64_t length = 0);
  110. Variant HHVM_FUNCTION(fputs,
  111. const Resource& handle,
  112. const String& data,
  113. int64_t length = 0);
  114. Variant HHVM_FUNCTION(fprintf,
  115. const Variant& handle,
  116. const String& format,
  117. const Array& args = null_array);
  118. Variant HHVM_FUNCTION(vfprintf,
  119. const Variant& handle,
  120. const Variant& format,
  121. const Variant& args);
  122. bool HHVM_FUNCTION(fflush,
  123. const Resource& handle);
  124. bool HHVM_FUNCTION(ftruncate,
  125. const Resource& handle,
  126. int64_t size);
  127. bool HHVM_FUNCTION(flock,
  128. const Resource& handle,
  129. int operation,
  130. VRefParam wouldblock = uninit_null());
  131. Variant HHVM_FUNCTION(fputcsv,
  132. const Resource& handle,
  133. const Array& fields,
  134. const String& delimiter = ",",
  135. const String& enclosure = "\"");
  136. Variant HHVM_FUNCTION(fgetcsv,
  137. const Resource& handle,
  138. int64_t length = 0,
  139. const String& delimiter = ",",
  140. const String& enclosure = "\"",
  141. const String& escape = "\\");
  142. ///////////////////////////////////////////////////////////////////////////////
  143. // file name based file operations
  144. Variant HHVM_FUNCTION(file_get_contents,
  145. const String& filename,
  146. bool use_include_path = false,
  147. const Variant& context = uninit_null(),
  148. int64_t offset = -1,
  149. int64_t maxlen = -1);
  150. Variant HHVM_FUNCTION(file_put_contents,
  151. const String& filename,
  152. const Variant& data,
  153. int flags = 0,
  154. const Variant& context = uninit_null());
  155. Variant HHVM_FUNCTION(file,
  156. const String& filename,
  157. int flags = 0,
  158. const Variant& context = uninit_null());
  159. Variant HHVM_FUNCTION(readfile,
  160. const String& filename,
  161. bool use_include_path = false,
  162. const Variant& context = uninit_null());
  163. bool HHVM_FUNCTION(move_uploaded_file,
  164. const String& filename,
  165. const String& destination);
  166. Variant HHVM_FUNCTION(parse_ini_file,
  167. const String& filename,
  168. bool process_sections = false,
  169. int scanner_mode = k_INI_SCANNER_NORMAL);
  170. Variant HHVM_FUNCTION(parse_ini_string,
  171. const String& ini,
  172. bool process_sections = false,
  173. int scanner_mode = k_INI_SCANNER_NORMAL);
  174. Variant HHVM_FUNCTION(md5_file,
  175. const String& filename,
  176. bool raw_output = false);
  177. Variant HHVM_FUNCTION(sha1_file,
  178. const String& filename,
  179. bool raw_output = false);
  180. ///////////////////////////////////////////////////////////////////////////////
  181. // shell commands
  182. bool HHVM_FUNCTION(chmod,
  183. const String& filename,
  184. int64_t mode);
  185. bool HHVM_FUNCTION(chown,
  186. const String& filename,
  187. const Variant& user);
  188. bool HHVM_FUNCTION(lchown,
  189. const String& filename,
  190. const Variant& user);
  191. bool HHVM_FUNCTION(chgrp,
  192. const String& filename,
  193. const Variant& group);
  194. bool HHVM_FUNCTION(lchgrp,
  195. const String& filename,
  196. const Variant& group);
  197. bool HHVM_FUNCTION(touch,
  198. const String& filename,
  199. int64_t mtime = 0,
  200. int64_t atime = 0);
  201. bool HHVM_FUNCTION(copy,
  202. const String& source,
  203. const String& dest,
  204. const Variant& context = uninit_null());
  205. bool HHVM_FUNCTION(rename,
  206. const String& oldname,
  207. const String& newname,
  208. const Variant& context = uninit_null());
  209. int64_t HHVM_FUNCTION(umask,
  210. const Variant& mask = null_variant);
  211. bool HHVM_FUNCTION(unlink,
  212. const String& filename,
  213. const Variant& context = uninit_null());
  214. bool HHVM_FUNCTION(link,
  215. const String& target,
  216. const String& link);
  217. bool HHVM_FUNCTION(symlink,
  218. const String& target,
  219. const String& link);
  220. String HHVM_FUNCTION(basename,
  221. const String& path,
  222. const String& suffix = null_string);
  223. bool HHVM_FUNCTION(fnmatch,
  224. const String& pattern,
  225. const String& filename,
  226. int flags = 0);
  227. Variant HHVM_FUNCTION(glob,
  228. const String& pattern,
  229. int flags = 0);
  230. Variant HHVM_FUNCTION(tempnam,
  231. const String& dir,
  232. const String& prefix);
  233. Variant HHVM_FUNCTION(tmpfile);
  234. ///////////////////////////////////////////////////////////////////////////////
  235. // stats functions
  236. Variant HHVM_FUNCTION(fileperms,
  237. const String& filename);
  238. Variant HHVM_FUNCTION(fileinode,
  239. const String& filename);
  240. Variant HHVM_FUNCTION(filesize,
  241. const String& filename);
  242. Variant HHVM_FUNCTION(fileowner,
  243. const String& filename);
  244. Variant HHVM_FUNCTION(filegroup,
  245. const String& filename);
  246. Variant HHVM_FUNCTION(fileatime,
  247. const String& filename);
  248. Variant HHVM_FUNCTION(filemtime,
  249. const String& filename);
  250. Variant HHVM_FUNCTION(filectime,
  251. const String& filename);
  252. Variant HHVM_FUNCTION(filetype,
  253. const String& filename);
  254. Variant HHVM_FUNCTION(linkinfo,
  255. const String& filename);
  256. bool HHVM_FUNCTION(is_writable,
  257. const String& filename);
  258. bool HHVM_FUNCTION(is_writeable,
  259. const String& filename);
  260. bool HHVM_FUNCTION(is_readable,
  261. const String& filename);
  262. bool HHVM_FUNCTION(is_executable,
  263. const String& filename);
  264. bool HHVM_FUNCTION(is_file,
  265. const String& filename);
  266. bool HHVM_FUNCTION(is_dir,
  267. const String& filename);
  268. bool HHVM_FUNCTION(is_link,
  269. const String& filename);
  270. bool HHVM_FUNCTION(is_uploaded_file,
  271. const String& filename);
  272. bool HHVM_FUNCTION(file_exists,
  273. const String& filename);
  274. Variant HHVM_FUNCTION(stat,
  275. const String& filename);
  276. Variant HHVM_FUNCTION(lstat,
  277. const String& filename);
  278. void HHVM_FUNCTION(clearstatcache,
  279. bool clear_realpath_cache = false,
  280. const Variant& filename = null_variant);
  281. Variant HHVM_FUNCTION(readlink_internal,
  282. const String& path,
  283. bool warning_compliance);
  284. Variant HHVM_FUNCTION(readlink,
  285. const String& path);
  286. Variant HHVM_FUNCTION(realpath,
  287. const String& path);
  288. Variant HHVM_FUNCTION(pathinfo,
  289. const String& path,
  290. int opt = 15);
  291. Variant HHVM_FUNCTION(disk_free_space,
  292. const String& directory);
  293. Variant HHVM_FUNCTION(diskfreespace,
  294. const String& directory);
  295. Variant HHVM_FUNCTION(disk_total_space,
  296. const String& directory);
  297. ///////////////////////////////////////////////////////////////////////////////
  298. // directory functions
  299. bool HHVM_FUNCTION(mkdir,
  300. const String& pathname,
  301. int64_t mode = 0777,
  302. bool recursive = false,
  303. const Variant& context = uninit_null());
  304. bool HHVM_FUNCTION(rmdir,
  305. const String& dirname,
  306. const Variant& context = uninit_null());
  307. String HHVM_FUNCTION(dirname,
  308. const String& path);
  309. Variant HHVM_FUNCTION(getcwd);
  310. bool HHVM_FUNCTION(chdir,
  311. const String& directory);
  312. bool HHVM_FUNCTION(chroot,
  313. const String& directory);
  314. Variant HHVM_FUNCTION(dir,
  315. const String& directory);
  316. Variant HHVM_FUNCTION(opendir,
  317. const String& path,
  318. const Variant& context = uninit_null());
  319. Variant HHVM_FUNCTION(readdir,
  320. const Variant& dir_handle = null_variant);
  321. void HHVM_FUNCTION(rewinddir,
  322. const Variant& dir_handle = null_variant);
  323. Variant HHVM_FUNCTION(scandir,
  324. const String& directory,
  325. bool descending = false,
  326. const Variant& context = uninit_null());
  327. void HHVM_FUNCTION(closedir,
  328. const Variant& dir_handle = null_variant);
  329. ///////////////////////////////////////////////////////////////////////////////
  330. }
  331. #endif // incl_HPHP_EXT_FILE_H_