Namespace: OpenEdge.Core
Class
File
Parent classes:
Progress.Lang.Object

Inherits: Progress.Lang.Object

/* *************************************************************************************************************************
Copyright (c) 2021 by Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
File:File
Purpose:Represents a filename, which may or not exist.
Author(s):pjudge
Created:2021-10-14
Notes:* The path elements (name, folder, extension, basename) are immutable once the object has been instantiated.




Method Summary
Options Name Purpose
CHARACTER AbsoluteFileName () /** Returns the absolute file name of this object, if the file exists. Resolved using FILE-INFO @param character An absolute path. If the file does not exist, or cannot be resolved, the unknown value is returned */
LOGICAL CanCreateFile () /** Returns a logical value indicating whether the file can be created. If the Name already exists (as any type), then FALSE is returned. If the Folder exists, and is either a FILE or not writable, then FALSE is returned. If the Folder does not exist, then return the value of the CanCreateFolder() method. Otherwise return TRUE. @return logical TRUE if the file can be created, FALSE otherwise */
LOGICAL CanCreateFolder () /** Returns a logical value indicating whether the folder can be created. If any of the parent folders are not directories or are not writable, then return FALSE. Otherwise return TRUE. @return logical TRUE if the folder can be created, FALSE otherwise */
LOGICAL CanWriteToFile () /* Indicates whether a file can be written to. @return logical TRUE if the file exists and can be written to. FALSE otherwise. */
LOGICAL CanWriteToFolder () /* Indicates whether the file's folder can be written to. If none of the folders exist then this method returns TRUE @return logical TRUE if the file exists and can be written to. FALSE otherwise. */
LOGICAL ContainsIllegalCharacters (character) /* Indicates whether a string has illegal characters anywhere in it. @param character A string to check @return logical TRUE if the string is not-null, and has at least one illegal character in it; FALSE otherwise */
LOGICAL CreateFile () /* Creates an empty file on disk. This method does NOT check whether the file can be created (via CanCreateFile), but rather simply tries to create the file, and returns FALSE if it fails. @return logical TRUE if the file was created. FALSE if the file already exists, or if an error wa raised during creation. */
LOGICAL CreateFolder () /* Creates this file's Folder This method does NOT check whether the folder can be created (via CanCreateFolder), but rather simply tries to create the folder tree, and returns FALSE if it fails. @return logical TRUE if the Folder was created. FALSE if the Folder already exists, or if an error was raised during creation */
LOGICAL Equals (Object)
FileInfoFindExistingParent (character) /* Find the first/nearest existing folder for a path. A path may be a folder or a file. @param character A path. */
LOGICAL FileInfoIsFileAndWritable () /* Checks if the current FILE-INFO is a FILE and has the WRITE flag set. @return logical TRUE if the current file-info is a file, and has the write flag set; FALSE otherwise */
LOGICAL FileInfoIsFolderAndWritable () /* Checks if the current FILE-INFO is a DIRECTORY and has the WRITE flag set. @return logical TRUE if the current file-info is a directory, and has the write flag set; FALSE otherwise */
FileInfoSetToFolder () /* Set the FILE-INFO FILE-NAME to the folder for this File. Uses "." if the folder is empty. */
CHARACTER GetSplitPath () /** Returns an array of path entries @return character[] May be indeterminate if the path is empty */
SplitFileName (character) /* Splits a /-delimited file name into its component parts @param character A complete file name */
CHARACTER ToString ()

Constructor Summary
Options Name Purpose
File (character) /* Constructor @param character A file name - not empty, not null. Cannot contain any of the following characters: <>:"|?* */
File (character, character) /* Constructor. Sanitises the filename - ie replaces illegal characters with the input replacement char(s). @param character A file name - not empty, not null, not "." @param character A/the replacement character that will replace the illegal characters. If ? is passed, no replacements are done, and the file name cannot contain any of the following characters: <>:"|?* */

Property Summary
Options Name Purpose
CHARACTER Basename
CHARACTER Extension
LOGICAL FileExists
CHARACTER Folder
LOGICAL FolderExists
CHARACTER Name


Method Detail
Top

CHARACTER AbsoluteFileName ()

Purpose: Returns the absolute file name of this object, if the file exists. Resolved using FILE-INFO
Returns CHARACTER
Top

LOGICAL CanCreateFile ()

Purpose: Returns a logical value indicating whether the file can be created.
If the Name already exists (as any type), then FALSE is returned.
If the Folder exists, and is either a FILE or not writable, then FALSE is returned.
If the Folder does not exist, then return the value of the CanCreateFolder() method.
Otherwise return TRUE.
Returns LOGICAL
logical TRUE if the file can be created, FALSE otherwise
Top

LOGICAL CanCreateFolder ()

Purpose: Returns a logical value indicating whether the folder can be created.
If any of the parent folders are not directories or are not writable, then
return FALSE.
Otherwise return TRUE.
Returns LOGICAL
logical TRUE if the folder can be created, FALSE otherwise
Top

LOGICAL CanWriteToFile ()

/* Indicates whether a file can be written to.
Returns LOGICAL
logical TRUE if the file exists and can be written to. FALSE otherwise.
Top

LOGICAL CanWriteToFolder ()

/* Indicates whether the file's folder can be written to.
If none of the folders exist then this method returns TRUE
Returns LOGICAL
logical TRUE if the file exists and can be written to. FALSE otherwise.
Top

LOGICAL ContainsIllegalCharacters (character)

/* Indicates whether a string has illegal characters anywhere in it.
Parameters:
pValue CHARACTER
Returns LOGICAL
logical TRUE if the string is not-null, and has at least one illegal character in it; FALSE otherwise
Top

LOGICAL CreateFile ()

/* Creates an empty file on disk.
This method does NOT check whether the file can be created (via CanCreateFile), but rather simply tries
to create the file, and returns FALSE if it fails.
Returns LOGICAL
logical TRUE if the file was created. FALSE if the file already exists, or if an error wa raised during creation.
Top

LOGICAL CreateFolder ()

/* Creates this file's Folder
This method does NOT check whether the folder can be created (via CanCreateFolder), but rather simply tries
to create the folder tree, and returns FALSE if it fails.
Returns LOGICAL
logical TRUE if the Folder was created. FALSE if the Folder already exists, or if an error was raised during creation
Top

LOGICAL Equals (Object)

Parameters:
pObj Progress.Lang.Object
Returns LOGICAL
Top

FileInfoFindExistingParent (character)

/* Find the first/nearest existing folder for a path. A path may be a folder
or a file.
Parameters:
pPath CHARACTER
Top

LOGICAL FileInfoIsFileAndWritable ()

/* Checks if the current FILE-INFO is a FILE and has the WRITE flag
set.
Returns LOGICAL
logical TRUE if the current file-info is a file, and has the write flag set; FALSE otherwise
Top

LOGICAL FileInfoIsFolderAndWritable ()

/* Checks if the current FILE-INFO is a DIRECTORY and has the WRITE flag
set.
Returns LOGICAL
logical TRUE if the current file-info is a directory, and has the write flag set; FALSE otherwise
Top

FileInfoSetToFolder ()

/* Set the FILE-INFO FILE-NAME to the folder for this File. Uses "." if the folder is empty.
Top

CHARACTER GetSplitPath ()

Purpose: Returns an array of path entries
Returns CHARACTER
character[] May be indeterminate if the path is empty
Top

SplitFileName (character)

/* Splits a /-delimited file name into its component parts
Parameters:
pFileName CHARACTER
Top

CHARACTER ToString ()

Returns CHARACTER


Constructor Detail
Top

File (character)

/* Constructor
Parameters:
pFileName CHARACTER
Top

File (character, character)

/* Constructor. Sanitises the filename - ie replaces illegal characters with the input replacement char(s).
are done, and the file name cannot contain any of the following characters: <>:"|?*
Parameters:
pFileName CHARACTER
pReplacementChar CHARACTER


Property Detail
Top

CHARACTER Basename

Returns CHARACTER
Top

CHARACTER Extension

Returns CHARACTER
Top

LOGICAL FileExists

Returns LOGICAL
Top

CHARACTER Folder

Returns CHARACTER
Top

LOGICAL FolderExists

Returns LOGICAL
Top

CHARACTER Name

Returns CHARACTER


Copyright © 2022 Progress Software Corporation. All rights Reserved.

Progress® OpenEdge® Release 12.5.0