core/model/modx/modfilehandler.class.php
- Package
- modx
\modDirectory
Representation of a directory
Not to be instantiated directly - you should implement your own derivative class.
- Parent(s)
- \modFileSystemResource
Properties
\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler
- Inherited_from
- \modFileSystemResource::$$fileHandler
array
$options= 'array()'
array()
Details- Type
- array
- Inherited_from
- \modFileSystemResource::$$options
string
$path= ''
- Type
- string
- Inherited_from
- \modFileSystemResource::$$path
Methods
__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
void
Constructor for modFileSystemResource
Inherited from: \modFileSystemResource::__construct()Name | Type | Description |
---|---|---|
$fh | \modFileHandler | A reference to the modFileHandler object |
$path | string | The path to the fs resource |
$options | array | An array of specific options |
chgrp(
mixed $grp
)
:
boolean
Sets the group permission for the fs resource
Inherited from: \modFileSystemResource::chgrp()Name | Type | Description |
---|---|---|
$grp | mixed |
Type | Description |
---|---|
boolean | True if successful |
chmod(
\octal $mode
)
:
boolean
Name | Type | Description |
---|---|---|
$mode | \octal |
Type | Description |
---|---|
boolean | True if successful |
chown(
mixed $owner
)
:
boolean
Name | Type | Description |
---|---|---|
$owner | mixed |
Type | Description |
---|---|
boolean | True if successful |
create(
string $mode
=
''
)
:
boolean
Actually creates the new directory on the file system.
Name | Type | Description |
---|---|---|
$mode | string | Optional. The permissions of the new directory. |
Type | Description |
---|---|
boolean | True if successful |
getGroup(
)
:
string
Gets the permission group for the fs resource
Inherited from: \modFileSystemResource::getGroup()Type | Description |
---|---|
string | The group name of the fs resource |
getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | string
Gets the parent containing directory of this fs resource
Inherited from: \modFileSystemResource::getParentDirectory()Name | Type | Description |
---|---|---|
$raw | boolean | Whether or not to return a modDirectory or string path |
Type | Description |
---|---|
\modDirectory | string | Returns either a modDirectory object of the parent directory, or the absolute path of the parent, depending on whether or not $raw is set to true. |
isReadable(
)
:
boolean
Check to see if the fs resource is readable
Inherited from: \modFileSystemResource::isReadable()Type | Description |
---|---|
boolean | True if readable |
isWritable(
)
:
boolean
Check to see if the fs resource is writable
Inherited from: \modFileSystemResource::isWritable()Type | Description |
---|---|
boolean | True if writable |
parseMode(
string $mode
=
''
)
:
boolean
Parses a string mode into octal format
Name | Type | Description |
---|---|---|
$mode | string |
Type | Description |
---|---|
boolean |
remove(
array $options
=
array()
)
:
boolean
Removes the directory from the file system, recursively removing subdirectories and files.
Name | Type | Description |
---|---|---|
$options | array | Options for removal. |
Type | Description |
---|---|
boolean | True if successful |
rename(
string $newPath
)
:
boolean
Name | Type | Description |
---|---|---|
$newPath | string | The new path for the fs resource |
Type | Description |
---|---|
boolean | True if successful |
\modFile
File implementation of modFileSystemResource
Not to be instantiated directly - you should implement your own derivative class.
- Parent(s)
- \modFileSystemResource
Properties
\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler
- Inherited_from
- \modFileSystemResource::$$fileHandler
array
$options= 'array()'
array()
Details- Type
- array
- Inherited_from
- \modFileSystemResource::$$options
string
$path= ''
- Type
- string
- Inherited_from
- \modFileSystemResource::$$path
Methods
__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
void
Constructor for modFileSystemResource
Inherited from: \modFileSystemResource::__construct()Name | Type | Description |
---|---|---|
$fh | \modFileHandler | A reference to the modFileHandler object |
$path | string | The path to the fs resource |
$options | array | An array of specific options |
chgrp(
mixed $grp
)
:
boolean
Sets the group permission for the fs resource
Inherited from: \modFileSystemResource::chgrp()Name | Type | Description |
---|---|---|
$grp | mixed |
Type | Description |
---|---|
boolean | True if successful |
chmod(
\octal $mode
)
:
boolean
Name | Type | Description |
---|---|---|
$mode | \octal |
Type | Description |
---|---|
boolean | True if successful |
chown(
mixed $owner
)
:
boolean
Name | Type | Description |
---|---|---|
$owner | mixed |
Type | Description |
---|---|
boolean | True if successful |
create(
string $content
=
'', string $mode
=
'w+'
)
:
boolean
Actually create the file on the file system
Name | Type | Description |
---|---|---|
$content | string | The content of the file to write |
$mode | string | The perms to write with the file |
Type | Description |
---|---|
boolean | True if successful |
getBaseName(
)
:
string
Gets the basename, or only the filename without the path, of the file
Type | Description |
---|---|
string | The basename of the file |
getContents(
)
:
string
Get the contents of the file
Type | Description |
---|---|
string | The contents of the file |
getExtension(
)
:
string
Gets the file extension of the file
Type | Description |
---|---|
string | The file extension of the file |
getGroup(
)
:
string
Gets the permission group for the fs resource
Inherited from: \modFileSystemResource::getGroup()Type | Description |
---|---|
string | The group name of the fs resource |
getLastAccessed(
string $timeFormat
=
'%b %d, %Y %I:%M:%S %p'
)
:
string
Gets the last accessed time of the file
Name | Type | Description |
---|---|---|
$timeFormat | string | The format, in strftime format, of the time |
Type | Description |
---|---|
string | The formatted time |
getLastModified(
string $timeFormat
=
'%b %d, %Y %I:%M:%S %p'
)
:
string
Gets the last modified time of the file
Name | Type | Description |
---|---|---|
$timeFormat | string | The format, in strftime format, of the time |
Type | Description |
---|---|
string | The formatted time |
getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | string
Gets the parent containing directory of this fs resource
Inherited from: \modFileSystemResource::getParentDirectory()Name | Type | Description |
---|---|---|
$raw | boolean | Whether or not to return a modDirectory or string path |
Type | Description |
---|---|
\modDirectory | string | Returns either a modDirectory object of the parent directory, or the absolute path of the parent, depending on whether or not $raw is set to true. |
getSize(
)
:
int
Gets the size of the file
Type | Description |
---|---|
int | The size of the file, in bytes |
isReadable(
)
:
boolean
Check to see if the fs resource is readable
Inherited from: \modFileSystemResource::isReadable()Type | Description |
---|---|
boolean | True if readable |
isWritable(
)
:
boolean
Check to see if the fs resource is writable
Inherited from: \modFileSystemResource::isWritable()Type | Description |
---|---|
boolean | True if writable |
parseMode(
string $mode
=
''
)
:
boolean
Parses a string mode into octal format
Name | Type | Description |
---|---|---|
$mode | string |
Type | Description |
---|---|
boolean |
- See
- \modFileSystemResource.parseMode
remove(
)
:
boolean
Deletes the file from the filesystem
Type | Description |
---|---|
boolean | True if successful |
rename(
string $newPath
)
:
boolean
Name | Type | Description |
---|---|---|
$newPath | string | The new path for the fs resource |
Type | Description |
---|---|
boolean | True if successful |
save(
string $content
=
null, string $mode
=
'w+'
)
:
boolean
Writes the content of the modFile object to the actual file.
Name | Type | Description |
---|---|---|
$content | string | Optional. If not using setContent, this will set the content to write. |
$mode | string | The mode in which to write |
Type | Description |
---|---|
boolean | The result of the fwrite |
setContent(
string $content
)
:
void
Temporarly set (but not save) the content of the file
Name | Type | Description |
---|---|---|
$content | string | The content |
setGroup(
string $grp
)
:
boolean
Name | Type | Description |
---|---|---|
$grp | string |
Type | Description |
---|---|
boolean |
- See
- \chgrp
\modFileHandler
Assists with directory/file manipulation
Properties
array
$config= 'array()'
An array of configuration properties for the class
array()
Details- Type
- array
\modContext|null
$context= 'null'
The current context in which this File Manager instance should operate
null
Details- Type
- \modContext | null
Methods
__construct(
\modX $modx, array $config
=
array()
)
:
void
The constructor for the modFileHandler class
Name | Type | Description |
---|---|---|
$modx | \modX | &$modx A reference to the modX object. |
$config | array | An array of options. |
getBasePath(
)
:
string
Get the modX base path for the user.
Type | Description |
---|---|
string | The base path |
getDirectoryFromFile(
string $fileName
)
:
string
Gets the directory path for a given file
Name | Type | Description |
---|---|---|
$fileName | string | The path for a file |
Type | Description |
---|---|
string | The directory path of the given file |
isBinary(
string $file
)
:
boolean
Tells if a file is a binary file or not.
Name | Type | Description |
---|---|---|
$file | string |
Type | Description |
---|---|
boolean | True if a binary file. |
make(
string $path, array $options
=
array(), string $overrideClass
=
''
)
:
mixed
Dynamically creates a modDirectory or modFile object.
The object is created based on the type of resource provided.
Name | Type | Description |
---|---|---|
$path | string | The absolute path to the filesystem resource. |
$options | array | Optional. An array of options for the object. |
$overrideClass | string | Optional. If provided, will force creation of the object as the specified class. |
Type | Description |
---|---|
mixed | The appropriate modFile/modDirectory object |
postfixSlash(
string $path
)
:
string
Ensures that the passed path has a / at the end
Name | Type | Description |
---|---|---|
$path | string |
Type | Description |
---|---|
string | The postfixed path |
\modFileSystemResource
Abstract class for handling file system resources (files or folders).
Not to be instantiated directly - you should implement your own derivative class.
- Children
- \modFile
- \modDirectory
Properties
\modFileHandler
$fileHandler= ''
- Type
- \modFileHandler
array
$options= 'array()'
array()
Details- Type
- array
Methods
__construct(
\modFileHandler $fh, string $path, array $options
=
array()
)
:
void
Constructor for modFileSystemResource
Name | Type | Description |
---|---|---|
$fh | \modFileHandler | A reference to the modFileHandler object |
$path | string | The path to the fs resource |
$options | array | An array of specific options |
chgrp(
mixed $grp
)
:
boolean
Sets the group permission for the fs resource
Name | Type | Description |
---|---|---|
$grp | mixed |
Type | Description |
---|---|
boolean | True if successful |
chmod(
\octal $mode
)
:
boolean
Chmods the resource to the specified mode.
Name | Type | Description |
---|---|---|
$mode | \octal |
Type | Description |
---|---|
boolean | True if successful |
chown(
mixed $owner
)
:
boolean
Sets the owner for the fs resource
Name | Type | Description |
---|---|---|
$owner | mixed |
Type | Description |
---|---|
boolean | True if successful |
exists(
)
:
boolean
Check to see if the fs resource exists
Type | Description |
---|---|
boolean | True if exists |
getGroup(
)
:
string
Gets the permission group for the fs resource
Type | Description |
---|---|
string | The group name of the fs resource |
getParentDirectory(
boolean $raw
=
false
)
:
\modDirectory | string
Gets the parent containing directory of this fs resource
Name | Type | Description |
---|---|---|
$raw | boolean | Whether or not to return a modDirectory or string path |
Type | Description |
---|---|
\modDirectory | string | Returns either a modDirectory object of the parent directory, or the absolute path of the parent, depending on whether or not $raw is set to true. |
getPath(
)
:
string
Get the path of the fs resource.
Type | Description |
---|---|
string | The path of the fs resource |
isLink(
)
:
boolean
Check to see if fs resource is symlink
Type | Description |
---|---|
boolean | True if symlink |
isReadable(
)
:
boolean
Check to see if the fs resource is readable
Type | Description |
---|---|
boolean | True if readable |
isWritable(
)
:
boolean
Check to see if the fs resource is writable
Type | Description |
---|---|
boolean | True if writable |
parseMode(
string $mode
=
''
)
:
\octal
Parses a string mode into octal format
Name | Type | Description |
---|---|---|
$mode | string | The octal to parse |
Type | Description |
---|---|
\octal | The new mode in octal format |
rename(
string $newPath
)
:
boolean
Renames the file/folder
Name | Type | Description |
---|---|---|
$newPath | string | The new path for the fs resource |
Type | Description |
---|---|
boolean | True if successful |