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


/* *************************************************************************************************************************
Copyright (c) 2022 by Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
File:Folder
Purpose:Represents a folder, which may or not exist
Author(s):pjudge
Created:2022-01-25
Notes:* Certain properties are marked NON-SERIALIZABLE since they
are read-only and depend on a physical folder being on
disk, and we need to check that on each call.
/* Indicates whether the path is writable. Returns TRUE if it exists, and FALSE otherwise.



Method Summary
  Options Name Purpose
  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 are converted to / @return character An absolute (file system) representation of this path */
  Add (File) /* Adds a file to this folder. The input file's basename is used to create a new File instance, that has this folder as the folder. So if this folder is "/some/path" , and a file "foo.pdf" is added, then the new file has a name of "/some/path/foo.pdf". Similarly, if a file "bar/baz.png" is added, then the new file has a name of "/some/path/baz.png". @param File A file to add */
  Add (Folder) /* Adds a sub-folder to this folder. The 'basename' of the folder is added to this folder. The 'basename' is the last path segment. If it is blank or / or // an error is thrown @param Folder The sub folder */
  LOGICAL Create () /* Creates this folder, if it does not exist This method does NOT check whether the folder can be created (via CanCreateFolder), but rather simply tries to create the folder, 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 this folder on disk. The folder, its files and any subfolders are deleted. @return logical TRUE if the folder exists, and has write permissions, and was deleted without any errors. FALSE otherwise */
  FileInfoFindExistingParent (character) /* Find the first/nearest existing folder for a path. A path may be a folder or a file. @param character A path. */
  ReadFolder (integer) /* Reads the contents of a folder, to a given depth. Depth value: -n = Don't read this folder, at all 0 = Read the current folder. Read files and folders, but don't read child folders' contents ? = read all the way down. Read all files and child folders n = read up to specified depth. At lowest level, read files and child folders, but not folders' contents @param integer The depth to read to. */
  SetFileInfo () /* Set the FILE-INFO FILE-NAME for this Folder. Uses "." if the folder Name is empty. */

Constructor Summary
  Options Name Purpose
  Folder (character) /* Constructor. @param character A folder name. Must have a value (not ?) */
  Folder (character, integer) /* Constructor. @param character A folder name. Must have a value (not ?) @param integer The depth to which to read the folder. See the ReadFolder() method for details. */

Property Summary
  Options Name Purpose
  LOGICAL CanCreate
  LOGICAL CanWrite
  UNKNOWN DATATYPE Files
  UNKNOWN DATATYPE Folders


Method Detail
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 are converted to /
Returns CHARACTER
  character An absolute (file system) representation of this path
Top

Add (File)

/* Adds a file to this folder.
The input file's basename is used to create a new File instance, that has this folder as
the folder. So if this folder is "/some/path" , and a file "foo.pdf" is added, then the
new file has a name of "/some/path/foo.pdf".
Similarly, if a file "bar/baz.png" is added, then the new file has a name of "/some/path/baz.png".
Parameters:
pFile OpenEdge.Core.File
 
Top

Add (Folder)

/* Adds a sub-folder to this folder. The 'basename' of the folder is added to this folder.
The 'basename' is the last path segment.
If it is blank or / or // an error is thrown
Parameters:
pFolder OpenEdge.Core.Folder
 
Top

LOGICAL Create ()

/* Creates this folder, if it does not exist
This method does NOT check whether the folder can be created (via CanCreateFolder), but rather simply tries
to create the folder, 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 this folder on disk. The folder, its files and any subfolders are deleted.
FALSE otherwise
Returns LOGICAL
  logical TRUE if the folder exists, and has write permissions, and was deleted without any errors.
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

ReadFolder (integer)

/* Reads the contents of a folder, to a given depth.
Depth value:
-n = Don't read this folder, at all
0 = Read the current folder. Read files and folders, but don't read child folders' contents
? = read all the way down. Read all files and child folders
n = read up to specified depth. At lowest level, read files and child folders, but not folders' contents
Parameters:
pDepth INTEGER
 
Top

SetFileInfo ()

/* Set the FILE-INFO FILE-NAME for this Folder. Uses "." if the folder Name is empty.


Constructor Detail
Top

Folder (character)

/* Constructor.
Parameters:
pFolder CHARACTER
 
Top

Folder (character, integer)

/* Constructor.
Parameters:
pFolder CHARACTER
 
pDepth INTEGER
 


Property Detail
Top

LOGICAL CanCreate

Returns LOGICAL
 
Top

LOGICAL CanWrite

Returns LOGICAL
 
Top

UNKNOWN DATATYPE Files

Returns UNKNOWN DATATYPE
 
Top

UNKNOWN DATATYPE Folders

Returns UNKNOWN DATATYPE