Skip to content
This repository
Browse code

Add @link to File and Folder utilities

  • Loading branch information...
commit 3248e34819937ba0082b675610a68a2c22087169 1 parent a821723
Kyle Robinson Young authored November 14, 2011
30  lib/Cake/Utility/File.php
@@ -80,6 +80,7 @@ class File {
80 80
  * @param string $path Path to file
81 81
  * @param boolean $create Create file if it does not exist (if true)
82 82
  * @param integer $mode Mode to apply to the folder holding the file
  83
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File
83 84
  */
84 85
 	public function __construct($path, $create = false, $mode = 0755) {
85 86
 		$this->Folder = new Folder(dirname($path), $create, $mode);
@@ -102,6 +103,7 @@ public function __destruct() {
102 103
  * Creates the File.
103 104
  *
104 105
  * @return boolean Success
  106
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::create
105 107
  */
106 108
 	public function create() {
107 109
 		$dir = $this->Folder->pwd();
@@ -121,6 +123,7 @@ public function create() {
121 123
  * @param string $mode A valid 'fopen' mode string (r|w|a ...)
122 124
  * @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
123 125
  * @return boolean True on success, false on failure
  126
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::open
124 127
  */
125 128
 	public function open($mode = 'r', $force = false) {
126 129
 		if (!$force && is_resource($this->handle)) {
@@ -147,6 +150,7 @@ public function open($mode = 'r', $force = false) {
147 150
  * @param string $mode A `fread` compatible mode.
148 151
  * @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
149 152
  * @return mixed string on success, false on failure
  153
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::read
150 154
  */
151 155
 	public function read($bytes = false, $mode = 'rb', $force = false) {
152 156
 		if ($bytes === false && $this->lock === null) {
@@ -182,6 +186,7 @@ public function read($bytes = false, $mode = 'rb', $force = false) {
182 186
  * @param mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
183 187
  * @param integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
184 188
  * @return mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
  189
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::offset
185 190
  */
186 191
 	public function offset($offset = false, $seek = SEEK_SET) {
187 192
 		if ($offset === false) {
@@ -202,6 +207,7 @@ public function offset($offset = false, $seek = SEEK_SET) {
202 207
  * @param string $data Data to prepare for writing.
203 208
  * @param boolean $forceWindows
204 209
  * @return string The with converted line endings.
  210
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::prepare
205 211
  */
206 212
 	public static function prepare($data, $forceWindows = false) {
207 213
 		$lineBreak = "\n";
@@ -218,6 +224,7 @@ public static function prepare($data, $forceWindows = false) {
218 224
  * @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
219 225
  * @param string $force force the file to open
220 226
  * @return boolean Success
  227
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::write
221 228
  */
222 229
 	public function write($data, $mode = 'w', $force = false) {
223 230
 		$success = false;
@@ -244,6 +251,7 @@ public function write($data, $mode = 'w', $force = false) {
244 251
  * @param string $data Data to write
245 252
  * @param string $force force the file to open
246 253
  * @return boolean Success
  254
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::append
247 255
  */
248 256
 	public function append($data, $force = false) {
249 257
 		return $this->write($data, 'a', $force);
@@ -253,6 +261,7 @@ public function append($data, $force = false) {
253 261
  * Closes the current file if it is opened.
254 262
  *
255 263
  * @return boolean True if closing was successful or file was already closed, otherwise false
  264
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::close
256 265
  */
257 266
 	public function close() {
258 267
 		if (!is_resource($this->handle)) {
@@ -265,6 +274,7 @@ public function close() {
265 274
  * Deletes the File.
266 275
  *
267 276
  * @return boolean Success
  277
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::delete
268 278
  */
269 279
 	public function delete() {
270 280
 		clearstatcache();
@@ -282,6 +292,7 @@ public function delete() {
282 292
  * Returns the File info.
283 293
  *
284 294
  * @return string The File extension
  295
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
285 296
  */
286 297
 	public function info() {
287 298
 		if ($this->info == null) {
@@ -297,6 +308,7 @@ public function info() {
297 308
  * Returns the File extension.
298 309
  *
299 310
  * @return string The File extension
  311
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
300 312
  */
301 313
 	public function ext() {
302 314
 		if ($this->info == null) {
@@ -312,6 +324,7 @@ public function ext() {
312 324
  * Returns the File name without extension.
313 325
  *
314 326
  * @return string The File name without extension.
  327
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
315 328
  */
316 329
 	public function name() {
317 330
 		if ($this->info == null) {
@@ -331,6 +344,7 @@ public function name() {
331 344
  * @param string $name The name of the file to make safe if different from $this->name
332 345
  * @param string $ext The name of the extension to make safe if different from $this->ext
333 346
  * @return string $ext the extension of the file
  347
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::safe
334 348
  */
335 349
 	public function safe($name = null, $ext = null) {
336 350
 		if (!$name) {
@@ -347,6 +361,7 @@ public function safe($name = null, $ext = null) {
347 361
  *
348 362
  * @param mixed $maxsize in MB or true to force
349 363
  * @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
  364
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::md5
350 365
  */
351 366
 	public function md5($maxsize = 5) {
352 367
 		if ($maxsize === true) {
@@ -365,6 +380,7 @@ public function md5($maxsize = 5) {
365 380
  * Returns the full path of the File.
366 381
  *
367 382
  * @return string Full path to file
  383
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
368 384
  */
369 385
 	public function pwd() {
370 386
 		if (is_null($this->path)) {
@@ -377,6 +393,7 @@ public function pwd() {
377 393
  * Returns true if the File exists.
378 394
  *
379 395
  * @return boolean true if it exists, false otherwise
  396
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::exists
380 397
  */
381 398
 	public function exists() {
382 399
 		return (file_exists($this->path) && is_file($this->path));
@@ -386,6 +403,7 @@ public function exists() {
386 403
  * Returns the "chmod" (permissions) of the File.
387 404
  *
388 405
  * @return string Permissions for the file
  406
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::perms
389 407
  */
390 408
 	public function perms() {
391 409
 		if ($this->exists()) {
@@ -398,6 +416,7 @@ public function perms() {
398 416
  * Returns the Filesize
399 417
  *
400 418
  * @return integer size of the file in bytes, or false in case of an error
  419
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::size
401 420
  */
402 421
 	public function size() {
403 422
 		if ($this->exists()) {
@@ -410,6 +429,7 @@ public function size() {
410 429
  * Returns true if the File is writable.
411 430
  *
412 431
  * @return boolean true if its writable, false otherwise
  432
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::writable
413 433
  */
414 434
 	public function writable() {
415 435
 		return is_writable($this->path);
@@ -419,6 +439,7 @@ public function writable() {
419 439
  * Returns true if the File is executable.
420 440
  *
421 441
  * @return boolean true if its executable, false otherwise
  442
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::executable
422 443
  */
423 444
 	public function executable() {
424 445
 		return is_executable($this->path);
@@ -428,6 +449,7 @@ public function executable() {
428 449
  * Returns true if the File is readable.
429 450
  *
430 451
  * @return boolean true if file is readable, false otherwise
  452
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readable
431 453
  */
432 454
 	public function readable() {
433 455
 		return is_readable($this->path);
@@ -437,6 +459,7 @@ public function readable() {
437 459
  * Returns the File's owner.
438 460
  *
439 461
  * @return integer the Fileowner
  462
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::owner
440 463
  */
441 464
 	public function owner() {
442 465
 		if ($this->exists()) {
@@ -449,6 +472,7 @@ public function owner() {
449 472
  * Returns the File's group.
450 473
  *
451 474
  * @return integer the Filegroup
  475
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::group
452 476
  */
453 477
 	public function group() {
454 478
 		if ($this->exists()) {
@@ -461,6 +485,7 @@ public function group() {
461 485
  * Returns last access time.
462 486
  *
463 487
  * @return integer timestamp Timestamp of last access time
  488
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastAccess
464 489
  */
465 490
 	public function lastAccess() {
466 491
 		if ($this->exists()) {
@@ -473,6 +498,7 @@ public function lastAccess() {
473 498
  * Returns last modified time.
474 499
  *
475 500
  * @return integer timestamp Timestamp of last modification
  501
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastChange
476 502
  */
477 503
 	public function lastChange() {
478 504
 		if ($this->exists()) {
@@ -485,6 +511,7 @@ public function lastChange() {
485 511
  * Returns the current folder.
486 512
  *
487 513
  * @return Folder Current folder
  514
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
488 515
  */
489 516
 	public function &Folder() {
490 517
 		return $this->Folder;
@@ -495,7 +522,8 @@ public function &Folder() {
495 522
  *
496 523
  * @param string $dest destination for the copy
497 524
  * @param boolean $overwrite Overwrite $dest if exists
498  
- * @return boolean Succes
  525
+ * @return boolean Success
  526
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::copy
499 527
  */
500 528
 	public function copy($dest, $overwrite = true) {
501 529
 		if (!$this->exists() || is_file($dest) && !$overwrite) {
25  lib/Cake/Utility/Folder.php
@@ -81,6 +81,7 @@ class Folder {
81 81
  * @param string $path Path to folder
82 82
  * @param boolean $create Create folder if not found
83 83
  * @param mixed $mode Mode (CHMOD) to apply to created folder, false to ignore
  84
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder
84 85
  */
85 86
 	public function __construct($path = false, $create = false, $mode = false) {
86 87
 		if (empty($path)) {
@@ -105,6 +106,7 @@ public function __construct($path = false, $create = false, $mode = false) {
105 106
  * Return current path.
106 107
  *
107 108
  * @return string Current path
  109
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::pwd
108 110
  */
109 111
 	public function pwd() {
110 112
 		return $this->path;
@@ -115,6 +117,7 @@ public function pwd() {
115 117
  *
116 118
  * @param string $path Path to the directory to change to
117 119
  * @return string The new path. Returns false on failure
  120
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::cd
118 121
  */
119 122
 	public function cd($path) {
120 123
 		$path = $this->realpath($path);
@@ -133,6 +136,7 @@ public function cd($path) {
133 136
  * @param mixed $exceptions Either an array or boolean true will not grab dot files
134 137
  * @param boolean $fullPath True returns the full path
135 138
  * @return mixed Contents of current directory as an array, an empty array on failure
  139
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::read
136 140
  */
137 141
 	public function read($sort = true, $exceptions = false, $fullPath = false) {
138 142
 		$dirs = $files = array();
@@ -181,6 +185,7 @@ public function read($sort = true, $exceptions = false, $fullPath = false) {
181 185
  * @param string $regexpPattern Preg_match pattern (Defaults to: .*)
182 186
  * @param boolean $sort Whether results should be sorted.
183 187
  * @return array Files that match given pattern
  188
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::find
184 189
  */
185 190
 	public function find($regexpPattern = '.*', $sort = false) {
186 191
 		list($dirs, $files) = $this->read($sort);
@@ -193,6 +198,7 @@ public function find($regexpPattern = '.*', $sort = false) {
193 198
  * @param string $pattern Preg_match pattern (Defaults to: .*)
194 199
  * @param boolean $sort Whether results should be sorted.
195 200
  * @return array Files matching $pattern
  201
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::findRecursive
196 202
  */
197 203
 	public function findRecursive($pattern = '.*', $sort = false) {
198 204
 		if (!$this->pwd()) {
@@ -234,6 +240,7 @@ protected function _findRecursive($pattern, $sort = false) {
234 240
  *
235 241
  * @param string $path Path to check
236 242
  * @return boolean true if windows path, false otherwise
  243
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath
237 244
  */
238 245
 	public static function isWindowsPath($path) {
239 246
 		return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
@@ -244,6 +251,7 @@ public static function isWindowsPath($path) {
244 251
  *
245 252
  * @param string $path Path to check
246 253
  * @return boolean true if path is absolute.
  254
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isAbsolute
247 255
  */
248 256
 	public static function isAbsolute($path) {
249 257
 		return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
@@ -254,6 +262,7 @@ public static function isAbsolute($path) {
254 262
  *
255 263
  * @param string $path Path to check
256 264
  * @return string Set of slashes ("\\" or "/")
  265
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::normalizePath
257 266
  */
258 267
 	public static function normalizePath($path) {
259 268
 		return Folder::correctSlashFor($path);
@@ -264,6 +273,7 @@ public static function normalizePath($path) {
264 273
  *
265 274
  * @param string $path Path to check
266 275
  * @return string Set of slashes ("\\" or "/")
  276
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::correctSlashFor
267 277
  */
268 278
 	public static function correctSlashFor($path) {
269 279
 		return (Folder::isWindowsPath($path)) ? '\\' : '/';
@@ -274,6 +284,7 @@ public static function correctSlashFor($path) {
274 284
  *
275 285
  * @param string $path Path to check
276 286
  * @return string Path with ending slash
  287
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::slashTerm
277 288
  */
278 289
 	public static function slashTerm($path) {
279 290
 		if (Folder::isSlashTerm($path)) {
@@ -288,6 +299,7 @@ public static function slashTerm($path) {
288 299
  * @param string $path Path
289 300
  * @param string $element Element to and at end of path
290 301
  * @return string Combined path
  302
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::addPathElement
291 303
  */
292 304
 	public static function addPathElement($path, $element) {
293 305
 		return rtrim($path, DS) . DS . $element;
@@ -298,6 +310,7 @@ public static function addPathElement($path, $element) {
298 310
  *
299 311
  * @param string $path The path to check.
300 312
  * @return boolean
  313
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inCakePath
301 314
  */
302 315
 	public function inCakePath($path = '') {
303 316
 		$dir = substr(Folder::slashTerm(ROOT), 0, -1);
@@ -312,6 +325,7 @@ public function inCakePath($path = '') {
312 325
  * @param string $path The path to check that the current pwd() resides with in.
313 326
  * @param boolean $reverse
314 327
  * @return boolean
  328
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inPath
315 329
  */
316 330
 	public function inPath($path = '', $reverse = false) {
317 331
 		$dir = Folder::slashTerm($path);
@@ -333,6 +347,7 @@ public function inPath($path = '', $reverse = false) {
333 347
  * @param boolean $recursive chmod recursively, set to false to only change the current directory.
334 348
  * @param array $exceptions array of files, directories to skip
335 349
  * @return boolean Returns TRUE on success, FALSE on failure
  350
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod
336 351
  */
337 352
 	public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
338 353
 		if (!$mode) {
@@ -383,6 +398,7 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr
383 398
  * @param mixed $exceptions Array of files to exclude, defaults to excluding hidden files.
384 399
  * @param string $type either file or dir. null returns both files and directories
385 400
  * @return mixed array of nested directories and files in each directory
  401
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
386 402
  */
387 403
 	public function tree($path = null, $exceptions = true, $type = null) {
388 404
 		if ($path == null) {
@@ -449,6 +465,7 @@ protected function _tree($path, $exceptions) {
449 465
  * @param string $pathname The directory structure to create
450 466
  * @param integer $mode octal value 0755
451 467
  * @return boolean Returns TRUE on success, FALSE on failure
  468
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
452 469
  */
453 470
 	public function create($pathname, $mode = false) {
454 471
 		if (is_dir($pathname) || empty($pathname)) {
@@ -487,6 +504,7 @@ public function create($pathname, $mode = false) {
487 504
  * Returns the size in bytes of this Folder and its contents.
488 505
  *
489 506
  * @return integer size in bytes of current folder
  507
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::dirsize
490 508
  */
491 509
 	public function dirsize() {
492 510
 		$size = 0;
@@ -523,6 +541,7 @@ public function dirsize() {
523 541
  *
524 542
  * @param string $path Path of directory to delete
525 543
  * @return boolean Success
  544
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete
526 545
  */
527 546
 	public function delete($path = null) {
528 547
 		if (!$path) {
@@ -579,6 +598,7 @@ public function delete($path = null) {
579 598
  *
580 599
  * @param mixed $options Either an array of options (see above) or a string of the destination directory.
581 600
  * @return boolean Success
  601
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
582 602
  */
583 603
 	public function copy($options = array()) {
584 604
 		if (!$this->pwd()) {
@@ -664,6 +684,7 @@ public function copy($options = array()) {
664 684
  *
665 685
  * @param array $options (to, from, chmod, skip)
666 686
  * @return boolean Success
  687
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move
667 688
  */
668 689
 	public function move($options) {
669 690
 		$to = null;
@@ -688,6 +709,7 @@ public function move($options) {
688 709
  * get messages from latest method
689 710
  *
690 711
  * @return array
  712
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::messages
691 713
  */
692 714
 	public function messages() {
693 715
 		return $this->_messages;
@@ -697,6 +719,7 @@ public function messages() {
697 719
  * get error from latest method
698 720
  *
699 721
  * @return array
  722
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::errors
700 723
  */
701 724
 	public function errors() {
702 725
 		return $this->_errors;
@@ -707,6 +730,7 @@ public function errors() {
707 730
  *
708 731
  * @param string $path Path to resolve
709 732
  * @return string The resolved path
  733
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
710 734
  */
711 735
 	public function realpath($path) {
712 736
 		$path = str_replace('/', DS, trim($path));
@@ -747,6 +771,7 @@ public function realpath($path) {
747 771
  *
748 772
  * @param string $path Path to check
749 773
  * @return boolean true if path ends with slash, false otherwise
  774
+ * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isSlashTerm
750 775
  */
751 776
 	public static function isSlashTerm($path) {
752 777
 		$lastChar = $path[strlen($path) - 1];

0 notes on commit 3248e34

Please sign in to comment.
Something went wrong with that request. Please try again.