Namespace: OpenEdge.Core
Type: Class File
Parent Classes:
Inherits: OpenEdge.Core.FileInfo


/* *************************************************************************************************************************
Copyright (c) 2021-2022 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.
are read-only and depend on a physical file being on
disk, and we need to check that on each call.



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 */
  CHARACTER AbsoluteFilePath () /** Returns the absolute path (folder) of this object, if it exists. Resolved using FILE-INFO. This may differ from the folder's AbsolutePath() when the file has a relative path, if the (relative) folder appears more than once in PROPATH. @param character An absolute path. If the file does not exist, or cannot be resolved, the unknown value is returned */
  CHARACTER AbsolutePath () /** Returns the absolute path. If the path does not exist on this host, the unknown value is returned. For Windows, any short paths - like C:\PROGRA~1 - are converted into their long paths - C:\Program Files. Backslashes are converted to / @return character An absolute (file system) representation of this path */
  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 CanReadFile () /* Indicates whether a file can be written to. @return logical TRUE if the file exists and can be written to. FALSE otherwise. */
  LOGICAL CanReadFolder () /* 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 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 Create () /* Creates the path on disk. Note that no error is thrown from this method; FALSE is returned instead. @return logical TRUE if the file was created. FALSE if the file already exists, or if an error wa raised during creation. */
  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 Delete () /* Deletes the file on disk @return logical TRUE if the file exists, and has write permissions, and was deleted without error. FALSE otherwise */
  LOGICAL DeleteFile () /* Deletes the file on disk @return logical TRUE if the file exists, and has write permissions, and was deleted without error. FALSE otherwise */
  OpenEdge.Core.Folder GetFolder () /* Returns this file's folder as an object representation @param Folder The folder instance */

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
  LOGICAL CanCreate
  LOGICAL CanWrite
  CHARACTER Extension
  LOGICAL FileExists
  CHARACTER Folder
  LOGICAL FolderExists
  INT64 Size


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

CHARACTER AbsoluteFilePath ()

Purpose: Returns the absolute path (folder) of this object, if it exists. Resolved using FILE-INFO.
This may differ from the folder's AbsolutePath() when the file has a relative path, if the (relative) folder
appears more than once in PROPATH.
Returns CHARACTER
 
Top

CHARACTER AbsolutePath ()

Purpose: Returns the absolute path.
If the path does not exist on this host, the unknown value is returned.
For Windows, any short paths - like C:\PROGRA~1 - are converted into their long paths - C:\Program Files.
Backslashes are converted to /
Returns CHARACTER
  character An absolute (file system) representation of this path
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 CanReadFile ()

/* 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 CanReadFolder ()

/* 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 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 Create ()

/* Creates the path on disk.
Note that no error is thrown from this method; FALSE is returned instead.
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 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 Delete ()

/* Deletes the file on disk
Returns LOGICAL
  logical TRUE if the file exists, and has write permissions, and was deleted without error. FALSE otherwise
Top

LOGICAL DeleteFile ()

/* Deletes the file on disk
Returns LOGICAL
  logical TRUE if the file exists, and has write permissions, and was deleted without error. FALSE otherwise
Top

OpenEdge.Core.Folder GetFolder ()

/* Returns this file's folder as an object representation
Returns OpenEdge.Core.Folder
 


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

LOGICAL CanCreate

Returns LOGICAL
 
Top

LOGICAL CanWrite

Returns LOGICAL
 
Top

CHARACTER Extension

Returns CHARACTER
 
Top

LOGICAL FileExists

Returns LOGICAL
 
Top

CHARACTER Folder

Returns CHARACTER
 
Top

LOGICAL FolderExists

Returns LOGICAL
 
Top

INT64 Size

Returns INT64