/functions/files.php

Description

files.php

This file includes various helper functions for working with the server filesystem.

Functions
file_has_long_lines (line 277)

Determine if there are lines in a file longer than a given length

  • return: TRUE as explained above, otherwise, (no long lines found) FALSE is returned.
boolean file_has_long_lines (string $filename, int $max_length)
  • string $filename: The full file path of the file to inspect
  • int $max_length: If any lines in the file are GREATER THAN this number, this function returns TRUE.
list_files (line 178)

Find files and/or directories in a given directory optionally limited to only those with the given file extension. If the directory is not found or cannot be opened, no error is generated; only an empty file list is returned.

  • return: The requested file/directory list(s).
  • since: 1.5.2
array list_files (string $directory_path, [ $extensions = ''], [boolean $return_filenames_only = TRUE], [boolean $include_directories = TRUE], [boolean $directories_only = FALSE], [boolean $separate_files_and_directories = FALSE], [boolean $only_sm = TRUE], mixed $extension)
  • string $directory_path: The path (relative or absolute) to the desired directory.
  • mixed $extension: The file extension filter - either an array of desired extension(s), or a comma-separated list of same (optional; default is to return all files (dirs).
  • boolean $return_filenames_only: When TRUE, only file/dir names are returned, otherwise the $directory_path string is prepended to each file/dir in the returned list (optional; default is filename/dirname only)
  • boolean $include_directories: When TRUE, directories are included (optional; default DO include directories).
  • boolean $directories_only: When TRUE, ONLY directories are included (optional; default is to include files too).
  • boolean $separate_files_and_directories: When TRUE, files and directories are returned in separate lists, so the return value is formatted as a two-element array with the two keys "FILES" and "DIRECTORIES", where corresponding values are lists of either all files or all directories (optional; default do not split up return array).
  • boolean $only_sm: When TRUE, a security check will limit directory access to only paths within the SquirrelMail installation currently being used (optional; default TRUE)
  • $extensions
sq_create_tempfile (line 29)

Generates a unique file in a specific directory and returns the file name (without the path).

  • return: FALSE when a failure occurs, otherwise a string containing the filename of the file only (not its full path)
  • since: 1.5.2
mixed sq_create_tempfile (directory $directory)
  • directory $directory: The directory within which to create the file
sq_is_writable (line 82)

PHP's is_writable() is broken in some versions due to either

safe_mode or because of problems correctly determining the actual file permissions under Windows. Under safe_mode or Windows, we'll try to actually write something in order to see for sure...

  • return: Whether or not the file or directory exists and is writable
  • since: 1.5.2
boolean sq_is_writable (string $path)
  • string $path: The full path to the file or directory to be tested

Documentation generated on Mon, 13 Jan 2020 04:22:28 +0100 by phpDocumentor 1.4.3