PageRenderTime 4ms CodeModel.GetById 510ms app.highlight 103ms RepoModel.GetById 169ms app.codeStats 0ms

/elpa/php-mode-20171204.23/php-filesystem.el

https://github.com/andreaja/dotemacs
Lisp | 590 lines | 489 code | 81 blank | 20 comment | 4 complexity | fbc9b79b5678a48821b82d04882e90da MD5 | raw file
  1;; Copyright (C) 2015  David Arroyo MenĂŠndez
  2
  3;; Author: David Arroyo MenĂŠndez <davidam@gnu.org>
  4;; Maintainer: David Arroyo MenĂŠndez <davidam@gnu.org>
  5
  6;; This file is free software; you can redistribute it and/or modify
  7;; it under the terms of the GNU General Public License as published by
  8;; the Free Software Foundation; either version 3, or (at your option)
  9;; any later version.
 10
 11;; This file is distributed in the hope that it will be useful,
 12;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14;; GNU General Public License for more details.
 15
 16;; You should have received a copy of the GNU General Public License
 17;; along with GNU Emacs; see the file COPYING.  If not, write to
 18;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 19;; Boston, MA 02110-1301 USA,
 20
 21;; To install php-ext.el:
 22;; You can add (load "path/php-ext/php-ext.el") to your .emacs
 23
 24;; Filesystem Functions
 25;; http://php.net/manual/en/ref.filesystem.php
 26;; file:///usr/share/doc/php-doc/html/ref.filesystem.html
 27
 28(define-skeleton php-basename
 29  "Insert an addcslashes statement"
 30  ""
 31  '(setq path (skeleton-read "Path: "))
 32  '(setq suffix (skeleton-read "Suffix? "))
 33  > "basename(" path ", " suffix ");" \n)
 34
 35(define-skeleton php-chgrp
 36  "Insert a chgrp statemt"
 37  ""
 38  '(setq filename (skeleton-read "Filename: "))
 39  '(setq group (skeleton-read "Group: "))
 40  > "chgrp(" filename ", " group ");" \n
 41)
 42
 43(define-skeleton php-chmod
 44  "Insert a chmod statement."
 45  ""
 46  '(setq filename (skeleton-read "Filename: "))
 47  '(setq perm (skeleton-read "Permissions: "))
 48  > "chmod(" filename ", " perm ");" \n
 49)
 50
 51(define-skeleton php-clearstatcache
 52  "Insert a clearstatcache statement."
 53  > "clearstatcache();" \n
 54  )
 55
 56(define-skeleton php-copy
 57  "Insert a clearstatcache statement."
 58  ""
 59  '(setq file1 (skeleton-read "Filename 1: "))
 60  '(setq file2 (skeleton-read "Filename 2: "))
 61  > "copy(" file1 ", " file2 ");" \n
 62  )
 63
 64(define-skeleton php-dirname
 65  "Insert a dirname statement."
 66  ""
 67  '(setq dir (skeleton-read "Dirname: "))
 68  > "dirname(" dir ");" \n
 69  )
 70
 71(define-skeleton php-disk_free_space
 72  "Insert a disk_free_space statement."
 73  ""
 74  '(setq dir (skeleton-read "Directory: "))
 75  > "disk_free_space(" dir ");" \n
 76  )
 77
 78(define-skeleton php-disk_total_space
 79  "Insert a disk_total_space statement."
 80  ""
 81  '(setq dir (skeleton-read "Directory: "))
 82  > "disk_total_space(" dir ");" \n
 83  )
 84
 85(define-skeleton php-fclose
 86  "Insert a fclose statement. fclose closes an open file pointer"
 87  ""
 88  '(setq handle (skeleton-read "handle: "))
 89  > "fclose(" handle ");" \n
 90  )
 91
 92(define-skeleton php-feof
 93  "Insert a feof statement. feof tests for end-of-file on a file pointer"
 94  ""
 95  '(setq file (skeleton-read "file: "))
 96  > "feof(" file ");" \n
 97  )
 98
 99(define-skeleton php-fflush
100  "Insert a fflush statement. fflush flushes the output to a file"
101  ""
102  '(setq file (skeleton-read "file: "))
103  > "fflush(" file ");" \n
104  )
105
106(define-skeleton php-fgetc
107  "Insert a fgetc statement. fgetc gets character from file pointer"
108  ""
109  '(setq handle (skeleton-read "handle: "))
110  > "fgetc(" handle ");" \n
111  )
112
113(define-skeleton php-fgetcsv
114  "Insert a fgetcsv statement. fgetcsv gets line from file pointer and parse for CSV fields"
115  ""
116  '(setq handle (skeleton-read "handle: "))
117  '(setq length (skeleton-read "length: "))
118  '(setq delimiter (skeleton-read "delimiter: "))
119  '(setq enclosure (skeleton-read "enclosure: "))
120  '(setq escape (skeleton-read "escape: "))
121  > "fgetc(" handle ", " length ", " delimiter ", " enclosure ", " escape ");" \n
122  )
123
124(define-skeleton php-fgets
125  "Insert a fgets statement. Fgets gets line from file pointer"
126  ""
127  '(setq handle (skeleton-read "handle: "))
128  '(setq length (skeleton-read "length: "))
129  > "fgets(" handle ", " length ");" \n
130  )
131
132(define-skeleton php-fgetss
133  "Insert a fgetss statement. Fgets gets line from file pointer and strip HTML tags"
134  ""
135  '(setq handle (skeleton-read "handle: "))
136  '(setq length (skeleton-read "length: "))
137  '(setq allowable_tags (skeleton-read "allowable_tags: "))
138  > "fgets(" handle ", " length ", " allowable_tags ");" \n
139  )
140
141(define-skeleton php-file_exists
142  "Insert a file_exists statement."
143  ""
144  '(setq file (skeleton-read "file: "))
145  > "file_exists(" file ");" \n
146  )
147
148(define-skeleton php-file_get_contents
149  "Insert a file_get_contents statement. file_get_contents reads entire file into a string"
150  ""
151  '(setq filename (skeleton-read "filename: "))
152  '(setq use_include_path (skeleton-read "use_include_path: "))
153  '(setq resource (skeleton-read "resource: "))
154  '(setq offset (skeleton-read "offset: "))
155  '(setq maxlen (skeleton-read "maxlen: "))
156  > "file_get_contents(" filename ", " use_include_path ", " resource ", " offset ", " maxlen ");" \n
157  )
158
159(define-skeleton php-file_put_contents
160  "Insert a file_put_contents statement. file_put_contents writes a string to a file"
161  ""
162  '(setq filename (skeleton-read "filename: "))
163  '(setq data (skeleton-read "data: "))
164  '(setq flags (skeleton-read "flags: "))
165  '(setq context (skeleton-read "context: "))
166  > "file_put_contents(" filename ", " data ", " flags ", " context ");" \n
167  )
168
169(define-skeleton php-file
170  "Insert a file statement. file reads a string into an array"
171  ""
172  '(setq filename (skeleton-read "filename: "))
173  '(setq flags (skeleton-read "flags: "))
174  '(setq context (skeleton-read "context: "))
175  > "file(" filename ", " flags ", " context ");" \n
176  )
177
178(define-skeleton php-fileatime
179  "Insert a fileatime statement. fileatime gets last access time of file"
180  ""
181  '(setq filename (skeleton-read "filename: "))
182  > "fileatime(" filename ");" \n
183  )
184
185(define-skeleton php-filectime
186  "Insert a filectime statement. filectime gets inode change time of file"
187  ""
188  '(setq filename (skeleton-read "filectime: "))
189  > "filectime(" filename ");" \n
190  )
191
192(define-skeleton php-fileinode
193  "Insert a fileinode statement. fileinode gets the file inode"
194  ""
195  '(setq filename (skeleton-read "fileinode: "))
196  > "fileinode(" filename ");" \n
197  )
198
199(define-skeleton php-filemtime
200  "Insert a filemtime statement. filemtime gets the file modification"
201  ""
202  '(setq filename (skeleton-read "filemtime: "))
203  > "filemtime(" filename ");" \n
204  )
205
206(define-skeleton php-fileowner
207  "Insert a fileowner statement. fileowner gets the file owner"
208  ""
209  '(setq filename (skeleton-read "fileowner: "))
210  > "fileowner(" filename ");" \n
211  )
212
213(define-skeleton php-fileperms
214  "Insert a fileperms statement. fileperms gets the file permissions"
215  ""
216  '(setq filename (skeleton-read "fileperms: "))
217  > "fileperms(" filename ");" \n
218  )
219
220(define-skeleton php-filesize
221  "Insert a filesize statement. filesize gets the size for the given file"
222  '(setq filename (skeleton-read "filesize: "))
223  > "filesize(" filename ");" \n
224  )
225
226(define-skeleton php-filetype
227  "Insert a filetype statement. filetype gets the type for the given file"
228  '(setq filename (skeleton-read "filetype: "))
229  > "filetype(" filename ");" \n
230  )
231
232(define-skeleton php-flock
233  "Insert a flock statement. flock is a portable advisory file locking"
234  ""
235  '(setq handle (skeleton-read "handle: "))
236  '(setq operation (skeleton-read "operation: "))
237  '(setq wouldblock (skeleton-read "wouldblock: "))
238  > "flock(" handle ", " operation ", " wouldblock ");" \n
239  )
240
241(define-skeleton php-fnmatch
242  "Insert a fnmatch statement. fnmatch match filename against a pattern"
243  ""
244  '(setq pattern (skeleton-read "pattern: "))
245  '(setq string (skeleton-read "string: "))
246  '(setq flags (skeleton-read "flags: "))
247  > "fnmatch(" pattern ", " string ", " flags ");" \n
248)
249
250(define-skeleton php-fopen
251  "Insert a fopen statement. fopen binds a named resource"
252  ""
253  '(setq filename (skeleton-read "filename: "))
254  '(setq mode (skeleton-read "mode: "))
255  '(setq use_include_path (skeleton-read "use_include_path: "))
256  '(setq context (skeleton-read "context: "))
257  > "fopen(" filename ", " mode ", " use_include_path ", " context ");" \n
258)
259
260(define-skeleton php-fpassthru
261  "Insert a fpassthru statement. fpassthru output all remaining data on a file pointer"
262  ""
263  '(setq handle (skeleton-read "handle: "))
264  > "fpassthru(" handle ");" \n
265)
266
267(define-skeleton php-fputcsv
268  "Insert a fputcsv statement. fputcsv formats line as csv and write to file pointer"
269  ""
270  '(setq handle (skeleton-read "handle: "))
271  '(setq fields (skeleton-read "fields: "))
272  '(setq delimiter (skeleton-read "delimiter: "))
273  '(setq enclosure (skeleton-read "enclosure: "))
274  > "fputcsv(" handle ", " fields ", " delimiter ", " enclosure ");" \n
275)
276
277(define-skeleton php-fread
278  "Insert a fread statement. Binary-safe file read"
279  ""
280  '(setq handle (skeleton-read "handle: "))
281  '(setq length (skeleton-read "length: "))
282  > "fread(" handle ", " length ");" \n
283)
284
285(define-skeleton php-fscanf
286  "Insert a fscanf statement. fscanf parses input from a file according to a format"
287  ""
288  '(setq handle (skeleton-read "handle: "))
289  '(setq format (skeleton-read "format: "))
290  > "fscanf(" handle ", " format ");" \n
291)
292
293(define-skeleton php-fseek
294  "Insert a fseek statement. fseek seeks on a file pointer."
295  ""
296  '(setq handle (skeleton-read "handle: "))
297  '(setq offset (skeleton-read "offset: "))
298  '(setq whence (skeleton-read "whence: "))
299  > "fseek(" handle ", " offset ", " whence ");" \n
300)
301
302(define-skeleton php-fstat
303  "Insert a fstat statement. fstat gets information about a file using an open file pointer"
304  ""
305  '(setq handle (skeleton-read "handle: "))
306  > "fstat(" handle ");" \n
307)
308
309(define-skeleton php-ftell
310  "Insert a ftell statement. ftell returns the current position of the file read/write pointer"
311  ""
312  '(setq handle (skeleton-read "handle: "))
313  > "ftell(" handle ");" \n
314)
315
316(define-skeleton php-ftruncate
317  "Insert a ftruncate statement. ftruncate truncates a file to a given length"
318  ""
319  '(setq handle (skeleton-read "handle: "))
320  '(setq size (skeleton-read "size: "))
321  > "ftruncate(" handle ", " size ");" \n
322)
323
324(define-skeleton php-fwrite
325  "Insert a fwrite statement. Binary safe file write"
326  '(setq handle (skeleton-read "handle: "))
327  '(setq string (skeleton-read "string: "))
328  '(setq length (skeleton-read "length: "))
329  > "fwrite(" handle ", " string ", " length ");" \n
330)
331
332(define-skeleton php-glob
333  "Insert a glob statement. Find pathnames matching a pattern"
334  '(setq pattern (skeleton-read "pattern: "))
335  '(setq flags (skeleton-read "flags: "))
336  > "glob(" pattern ", " flags ");" \n
337)
338
339(define-skeleton php-is_dir
340  "Insert a is_dir statement. is_dir tells whether the filename is a directory"
341  ""
342  '(setq filename (skeleton-read "filename: "))
343  > "is_dir(" filename ");" \n
344)
345
346(define-skeleton php-is_executable
347  "Insert a is_executable statement. is_executable tells whether the filename is a executable"
348  ""
349  '(setq filename (skeleton-read "filename: "))
350  > "is_executable(" filename ");" \n
351)
352
353(define-skeleton php-is_file
354  "Insert a is_file statement. is_file tells whether the filename is a regular file"
355  '(setq filename (skeleton-read "filename: "))
356  > "is_file(" filename ");" \n
357)
358
359(define-skeleton php-is_link
360  "Insert a is_link statement. is_link tells whether the filename is a symbolic link"
361  ""
362  '(setq filename (skeleton-read "filename: "))
363  > "is_link(" filename ");" \n
364)
365
366(define-skeleton php-is_readable
367  "Insert a is_readable statement. is_readable tells whether the filename is a readable"
368  ""
369  '(setq filename (skeleton-read "filename: "))
370  > "is_readable(" filename ");" \n
371)
372
373(define-skeleton php-is_uploaded_file
374  "Insert a is_uploaded_file statement. is_uploaded_file tells whether the filename is a executable"
375  ""
376  '(setq filename (skeleton-read "filename: "))
377  > "is_uploaded_file(" filename ");" \n
378)
379
380(define-skeleton php-is_writable
381  "Insert a is_writable statement. is_writable tells whether the filename is a writable"
382  ""
383  '(setq filename (skeleton-read "filename: "))
384  > "is_writable(" filename ");" \n
385)
386
387(define-skeleton php-lchgrp
388  "Insert a lchgrp statement. lchgrp changes group ownership of symlink"
389  ""
390  '(setq filename (skeleton-read "filename: "))
391  '(setq group (skeleton-read "group: "))
392  > "lchgrp(" filename ", " group ");" \n
393)
394
395(define-skeleton php-lchown
396  "Insert a lchown statement. lchown changes user ownership of symlink"
397  ""
398  '(setq filename (skeleton-read "filename: "))
399  '(setq user (skeleton-read "user: "))
400  > "lchown(" filename ", " user ");" \n
401)
402
403(define-skeleton php-link 
404  "Insert a link statement. link creates a hard link"
405  ""
406  '(setq target (skeleton-read "target of the link: "))
407  '(setq link (skeleton-read "link: "))
408  > "link(" target ", " link ");" \n
409)
410
411(define-skeleton php-linkinfo 
412  "Insert a linkinfo statement. linkinfo gets information about a link"
413  ""
414  '(setq path (skeleton-read "path of the link: "))
415  > "linkinfo(" path ");" \n
416)
417
418(define-skeleton php-lstat 
419  "Insert a lstat statement. lstat gives information about a symbolic link or file"
420  ""
421  '(setq path (skeleton-read "path of the link: "))
422  > "lstat(" path ");" \n
423)
424
425(define-skeleton php-mkdir 
426  "Insert a mkdir statement. mkdir makes a directory"
427  ""
428  '(setq path (skeleton-read "path: "))
429  '(setq mode (skeleton-read "permissions mode (numeric): "))
430  '(setq recursive (skeleton-read "recursive: "))
431  '(setq resource (skeleton-read "context: "))
432  > "mkdir(" path ", " mode ", " recursive ", " resource ");" \n
433)
434
435(define-skeleton php-move_uploaded_file
436  "Insert a move_uploaded_file statement. move an uploaded file to a new location"
437  ""
438  '(setq filename (skeleton-read "filename: "))
439  '(setq destination (skeleton-read "destination: "))
440  > "move_uploaded_file(" filename ", " destination ");" \n
441)
442
443(define-skeleton php-parse_ini_file
444  "Insert a parse_ini_file statement. parse_ini_file parses a configuration file"
445  ""
446  '(setq filename (skeleton-read "filename: "))
447  '(setq process_sections (skeleton-read "process sections: "))
448  '(setq scanner_mode (skeleton-read "scanner mode: "))
449  > "parse_ini_file(" filename ", " process_sections ", " scanner_mode ");" \n
450)
451
452(define-skeleton php-parse_ini_string
453  "Insert a parse_ini_string statement. parse_ini_string parses a configuration string"
454  ""
455  '(setq string (skeleton-read "string: "))
456  '(setq process_sections (skeleton-read "process sections: "))
457  '(setq scanner_mode (skeleton-read "scanner mode: "))
458  > "parse_ini_string(" string ", " process_sections ", " scanner_mode ");" \n
459)
460
461(define-skeleton php-pathinfo
462  "Insert a pathinfo statement. pathinfo returns information about a file path"
463  ""
464  '(setq path (skeleton-read "path: "))
465  '(setq options (skeleton-read "options: "))
466  > "pathinfo(" path ", " options ");" \n
467)
468
469(define-skeleton php-pclose 
470  "Insert a pclose statement. pclose closes process file pointer"
471  ""
472  '(setq handle (skeleton-read "handle: "))
473  > "pclose(" handle ");" \n
474)
475
476(define-skeleton php-popen 
477  "Insert a popen statement. popen opens process file pointer"
478  ""
479  '(setq command (skeleton-read "command: "))
480  '(setq mode (skeleton-read "mode: "))
481  > "popen(" command ", " mode ");" \n
482)
483
484(define-skeleton php-readfile
485  "Insert a readfile statement. readfile outputs a file"
486  ""
487  '(setq filename (skeleton-read "filename: "))
488  '(setq use_include_path (skeleton-read "use_include_path: "))
489  '(setq context (skeleton-read "context: "))
490  > "readfile(" filename ", " use_include_path ", " context ");" \n
491)
492
493(define-skeleton php-readlink
494  "Insert a readlink statement. readlink returns the target of the symbolic link."
495  ""
496  '(setq path (skeleton-read "path: "))
497  > "readlink(" path ");" \n
498)
499
500(define-skeleton php-realpath_cache_get
501  "Insert a realpath_cache_get statement. Returns an array of realpath cache entries."
502  > "realpath_cache_get();" \n
503)
504
505(define-skeleton php-realpath_cache_size
506  "Insert a realpath_cache_size statement. Get the amount of memory used by the realpath cache"
507  > "realpath_cache_size();" \n
508)
509
510
511(define-skeleton php-realpath
512  "Insert a realpath statement. realpath expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path and returns the canonicalized absolute pathname."
513  ""
514  '(setq path (skeleton-read "path: "))
515  > "realpath(" path ");" \n
516)
517
518(define-skeleton php-rename
519  "Insert a rename statement. Renames a file or directory"
520  ""
521  '(setq oldname (skeleton-read "oldname: "))
522  '(setq newname (skeleton-read "newname: "))
523  '(setq context (skeleton-read "context: "))
524  > "rename(" oldname ", " newname ", " context ");" \n
525)
526
527(define-skeleton php-rewind 
528  "Insert a rewind statement. Rewind the position of a file pointer"
529  ""
530  '(setq handle (skeleton-read "handle: "))
531  > "rewind(" handle ");" \n
532)
533
534(define-skeleton php-rmdir
535  "Insert a rmdir statement. Removes directory."
536  ""
537  '(setq dirname (skeleton-read "dirname: "))
538  > "rmdir(" dirname ");" \n
539)
540
541(define-skeleton php-stat
542  "Insert a stat statement. Gives information about a file."
543  '(setq filename (skeleton-read "filename: "))
544  > "stat(" filename ");" \n
545)
546
547(define-skeleton php-symlink
548  "Insert a symlink statement. symlink creates a symbolic link."
549  ""
550  '(setq target (skeleton-read "target: "))
551  '(setq link (skeleton-read "link: "))
552  > "symlink(" target ", " link ");" \n
553)
554
555(define-skeleton php-tempnam
556  "Insert a tempname statement. tempnam creates file with unique file name."
557  ""
558  '(setq dir (skeleton-read "directory: "))
559  '(setq prefix (skeleton-read "prefix: "))
560  > "tempnam(" dir ", " prefix ");" \n
561)
562
563(define-skeleton php-tmpfile
564  "Insert a tmpfile statement. tmpfile creates a temporary file."
565  > "tmpfile();" \n
566)
567
568(define-skeleton php-touch
569  "Insert a touch statement. touch set access and modification time of file."
570  ""
571  '(setq filename (skeleton-read "filename: "))
572  '(setq time (skeleton-read "time: "))
573  '(setq atime (skeleton-read "atime: "))
574  > "touch(" filename ", " time ", " atime ");" \n
575)
576
577(define-skeleton php-umask
578  "Insert umask statement. Changes the current umask."
579  ""
580  '(setq mask (skeleton-read "mask: "))
581  > "umask(" mask ");" \n
582)
583
584(define-skeleton php-unlink
585  "Insert unlink statement. Deletes a file."
586  ""
587  '(setq filename (skeleton-read "filename: "))
588  '(setq context (skeleton-read "context: "))
589  > "unlink(" filename ", " context ");" \n
590)