HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: Abstract file manager

» Return to Contents



The abstract file manager allows easy and transparent file system maintenance, even when it has to be piped through FTP.

sources/abstract_file_manager.php

Global_functions_abstract_file_manager.php

Function summary

void init__abstract_file_manager ()
void ftp_chmod (resource conn, integer access, PATH path)
void force_have_afm_details ()
void get_afm_form ()
tempcode get_afm_form_fields ()
~resource _ftp_info (boolean light_fail)
integer _translate_dir_access (boolean world_access)
integer _translate_file_access (boolean world_access, ID_TEXT file_type)
string _access_string (integer access_int)
PATH _rescope_path (PATH path)
void afm_set_perms (PATH basic_path, boolean world_access)
void afm_make_directory (PATH basic_path, boolean world_access, boolean recursive)
array _get_dir_tree (PATH base, PATH at)
void afm_delete_directory (PATH basic_path, boolean recursive)
void afm_make_file (PATH basic_path, string contents, boolean world_access)
string afm_read_file (PATH path)
void afm_copy (PATH old_path, PATH new_path, boolean world_access)
void afm_move (PATH basic_old_path, PATH basic_new_path)
void afm_delete_file (PATH basic_path)

void init__abstract_file_manager()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void ftp_chmod(resource conn, integer access, PATH path)

FTP: Change a file's permissions.

Parameters…

Name conn
Description The FTP connection.
Type resource

Name access
Description The permissions desired.
Type integer

Name path
Description The file path.
Type PATH

(No return value)


Return to the function index for this class Expand: View the source code to this function

void force_have_afm_details()

Make sure that the AFM connection details have been posted. If not, get them and loop back.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void get_afm_form()

Force an AFM login.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

tempcode get_afm_form_fields()

Get the fields that need to be filled in to know how to do an AFM connection.

Parameters…

Returns…

Description The form fields.
Type tempcode

Return to the function index for this class Expand: View the source code to this function

~resource _ftp_info(boolean light_fail)

Return the FTP connection, from stored/posted details.

Parameters…

Name light_fail
Description Whether to simply echo-out errors.
Default value boolean-false
Type boolean

Returns…

Description The FTP connection (false: not connecting via FTP).
Type ~resource

Return to the function index for this class Expand: View the source code to this function

integer _translate_dir_access(boolean world_access)

Translate truth about needing world write access to a directory to absolute permissions.

Parameters…

Name world_access
Description Whether world directory access is required.
Type boolean

Returns…

Description The absolute permission.
Type integer

Return to the function index for this class Expand: View the source code to this function

integer _translate_file_access(boolean world_access, ID_TEXT file_type)

Translate truth about needing world write access to a file to absolute permissions.

Parameters…

Name world_access
Description Whether world file access is required.
Type boolean

Name file_type
Description The file type (blank: don't care).
Default value
Type ID_TEXT

Returns…

Description The absolute permission.
Type integer

Return to the function index for this class Expand: View the source code to this function

string _access_string(integer access_int)

Convert an integer permission to the string version.

Parameters…

Name access_int
Description The integer permission.
Type integer

Returns…

Description The string version.
Type string

Return to the function index for this class Expand: View the source code to this function

PATH _rescope_path(PATH path)

Rescope an ocPortal path to a path suitable for the AFM connection.

Parameters…

Name path
Description Original path.
Type PATH

Returns…

Description Rescoped path.
Type PATH

Return to the function index for this class Expand: View the source code to this function

void afm_set_perms(PATH basic_path, boolean world_access)

Sets permissions over the open AFM connection.

Parameters…

Name basic_path
Description The path of the file/directory we are setting permissions of.
Type PATH

Name world_access
Description Whether world access is required.
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

void afm_make_directory(PATH basic_path, boolean world_access, boolean recursive)

Make a directory over the open AFM connection.

Parameters…

Name basic_path
Description The path to and of the directory we are making.
Type PATH

Name world_access
Description Whether world access is required.
Type boolean

Name recursive
Description Whether we should recursively make any directories that are missing in the given path, until we can make the final directory.
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

array _get_dir_tree(PATH base, PATH at)

Get a list of files under a directory.

Parameters…

Name base
Description The base directory for the search.
Type PATH

Name at
Description The directory where we are searching under.
Default value
Type PATH

Returns…

Description An array of directories found under this recursive level.
Type array

Return to the function index for this class Expand: View the source code to this function

void afm_delete_directory(PATH basic_path, boolean recursive)

Delete a directory over the open AFM connection.

Parameters…

Name basic_path
Description The path to and of the directory we are deleting.
Type PATH

Name recursive
Description Whether we should recursively delete any child files and directories.
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

void afm_make_file(PATH basic_path, string contents, boolean world_access)

Make a new file over the open AFM connection. Will overwrite if already exists (assuming has access).

Parameters…

Name basic_path
Description The path to the file we are making.
Type PATH

Name contents
Description The desired file contents.
Type string

Name world_access
Description Whether world access is required.
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

string afm_read_file(PATH path)

Read a file (not actually over the open AFM connection, but same result: we can do this directly).

Parameters…

Name path
Description The path to the file we are reading.
Type PATH

Returns…

Description The contents of the file.
Type string

Return to the function index for this class Expand: View the source code to this function

void afm_copy(PATH old_path, PATH new_path, boolean world_access)

Copies a file (NOT a directory) on the open AFM connection.

Parameters…

Name old_path
Description The path to the file we are copying.
Type PATH

Name new_path
Description The target path.
Type PATH

Name world_access
Description Whether world access is required for the copy.
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

void afm_move(PATH basic_old_path, PATH basic_new_path)

Moves a file on the open AFM connection.

Parameters…

Name basic_old_path
Description The path to the file we are moving from.
Type PATH

Name basic_new_path
Description The target path.
Type PATH

(No return value)


Return to the function index for this class Expand: View the source code to this function

void afm_delete_file(PATH basic_path)

Deletes a file (NOT a directory) on the open AFM connection.

Parameters…

Name basic_path
Description The path to the file we are deleting.
Type PATH

(No return value)


Return to the function index for this class Expand: View the source code to this function