Table of Contents

Interface IStdFileSystemModule

Namespace
RDCore.SDK.Runtime.Abstract.StdLib
Assembly
RDCore.SDK.dll

MS-VBAL 6.1.2.5 FileSystem Module

[StdLibModule(null)]
public interface IStdFileSystemModule

Remarks

Formalizes the public interface of the standard library VBA.FileSystem module.

What a member does to the machine - a directory listed, a file copied or deleted, the current directory changed - goes through the session's IFileChannels, the one seam every file statement goes through too: what an administrator restricts, and a test fakes, there. What the specification leaves to the implementation, and the errors it does not name, are MS-VBA's, recorded in Excel.

Methods

ChDir(VBStringValue)

MS-VBAL 6.1.2.5.2.1 ChDir Changes the current directory, but not the current drive.

RuntimeSemanticsEvaluationResult ChDir(VBStringValue path)

Parameters

path VBStringValue

The directory.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Error 76 Path not found for a directory that does not exist, or a zero-length String.

ChDrive(VBStringValue)

MS-VBAL 6.1.2.5.2.2 ChDrive Changes the current drive.

RuntimeSemanticsEvaluationResult ChDrive(VBStringValue drive)

Parameters

drive VBStringValue

The drive.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

A zero-length String changes nothing, and a drive is its first letter. Error 68 Device unavailable for a letter that is no drive.

CurDir(VBVariantValue?)

MS-VBAL 6.1.2.5.1.1 CurDir Gets the current directory of a drive.

RuntimeSemanticsEvaluationResult<VBVariantValue> CurDir(VBVariantValue? drive = null)

Parameters

drive VBVariantValue

The drive.

Returns

RuntimeSemanticsEvaluationResult<VBVariantValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

The current drive's when drive is omitted or a zero-length String; a drive is its first letter, so "C" and "C:\Temp" are one drive. As in MS-VBA: error 68 Device unavailable for a letter that is no drive, error 5 for a drive that is no letter.

CurDirString(VBVariantValue?)

MS-VBAL 6.1.2.5.1.1 CurDir Gets the current directory of a drive.

[StdLibMember("CurDir$")]
RuntimeSemanticsEvaluationResult<VBStringValue> CurDirString(VBVariantValue? drive = null)

Parameters

drive VBVariantValue

The drive.

Returns

RuntimeSemanticsEvaluationResult<VBStringValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

The current drive's when drive is omitted or a zero-length String; a drive is its first letter, so "C" and "C:\Temp" are one drive. As in MS-VBA: error 68 Device unavailable for a letter that is no drive, error 5 for a drive that is no letter.

Dir(VBVariantValue?, VBFileAttribute)

MS-VBAL 6.1.2.5.1.2 Dir Gets the name of a file or a directory that matches a pattern, or the next one that matches the pattern last given.

RuntimeSemanticsEvaluationResult<VBStringValue> Dir(VBVariantValue? pathName = null, VBFileAttribute attributes = VBFileAttribute.VBNormal)

Parameters

pathName VBVariantValue

The pattern: a file name, with wildcards, that can include a directory and a drive.

attributes VBFileAttribute

The attributes of the files, besides the normal ones, that match.

Returns

RuntimeSemanticsEvaluationResult<VBStringValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel):

  • the name has no directory part, and is spelled as the file system spells it; names match a pattern whatever their case, * and ? being wildcards, and come in the order of their upper-case spelling. The directory the pattern is in is found as the file system finds it: whatever its case on Windows, by its case on a file system whose names are, as Linux's are;
  • a pattern that names a directory, ending in a separator, matches what is in it; a directory itself only matches with VBDirectory, which matches . and .. too, and files with it;
  • a hidden or a system file only matches with VBHidden or VBSystem;
  • what matches nothing - a directory or a drive that does not exist included - is a zero-length String;
  • with no pattern, the next match of the last one, a zero-length String when there is none; error 5 when there is no pattern to go on with - none was given, or the last match was already given.

EOF(VBIntegerValue)

MS-VBAL 6.1.2.5.1.3 EOF Gets whether the file-pointer-position of a file is at its end (MS-VBAL §5.4.5).

RuntimeSemanticsEvaluationResult<VBBooleanValue> EOF(VBIntegerValue fileNumber)

Parameters

fileNumber VBIntegerValue

The file number.

Returns

RuntimeSemanticsEvaluationResult<VBBooleanValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

True for a file opened for Input once nothing is left to read; always, for one opened for Output or Append; and for one opened Random or Binary, once the last Get could not read an entire record - reading the last byte is not enough (recorded in Excel). Error 52 for a file number that is not open.

FileAttr(VBIntegerValue, VBIntegerValue?)

MS-VBAL 6.1.2.5.1.4 FileAttr Gets the mode a file was opened in: 1 Input, 2 Output, 4 Random, 8 Append, 32 Binary.

RuntimeSemanticsEvaluationResult<VBLongValue> FileAttr(VBIntegerValue fileNumber, VBIntegerValue? returnType = null)

Parameters

fileNumber VBIntegerValue

The file number.

returnType VBIntegerValue

What to get.

Returns

RuntimeSemanticsEvaluationResult<VBLongValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Only returnType 1 means anything: 2, the file's operating-system handle, is error 5 in 64-bit MS-VBA (recorded in Excel), and in RD-VBA, which has no handle to give; so is any other. Error 52 for a file number that is not open.

FileCopy(VBStringValue, VBStringValue)

MS-VBAL 6.1.2.5.2.3 FileCopy Copies a file, replacing the destination if it exists.

RuntimeSemanticsEvaluationResult FileCopy(VBStringValue source, VBStringValue destination)

Parameters

source VBStringValue

The path of the file to copy.

destination VBStringValue

The path of the copy.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel): error 55 File already open when the destination is open, or the source is open in any mode but Input; 53 for a source that does not exist, 52 for a pattern, 76 for a destination whose directory does not exist, 75 for a destination that is a directory.

FileDateTime(VBStringValue)

MS-VBAL 6.1.2.5.1.5 FileDateTime Gets the date and time a file, or a directory, was last modified.

RuntimeSemanticsEvaluationResult<VBVariantValue> FileDateTime(VBStringValue pathName)

Parameters

pathName VBStringValue

The file's path.

Returns

RuntimeSemanticsEvaluationResult<VBVariantValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Error 53 File not found for what does not exist, error 52 for a pattern.

FileLen(VBStringValue)

MS-VBAL 6.1.2.5.1.6 FileLen Gets the length of a file, in bytes.

RuntimeSemanticsEvaluationResult<VBLongValue> FileLen(VBStringValue pathName)

Parameters

pathName VBStringValue

The file's path.

Returns

RuntimeSemanticsEvaluationResult<VBLongValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel): the length the file has on the file system, which is not what a channel that has it open has written to it yet (LOF is) - 0 for one opened for Output, the length it had for one opened for Append; a directory's is 0. Error 53 File not found for what does not exist, error 52 for a pattern.

FreeFile(VBVariantValue?)

MS-VBAL 6.1.2.5.1.7 FreeFile Gets the next file number available for an Open statement to use (§5.4.5).

RuntimeSemanticsEvaluationResult<VBIntegerValue> FreeFile(VBVariantValue? rangeNumber = null)

Parameters

rangeNumber VBVariantValue

Which range to take the number from: 0 — the default — for 1-255, and 1 for 256-511. The two halves exist so that a caller can keep its own channels away from another's.

Returns

RuntimeSemanticsEvaluationResult<VBIntegerValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

👉 The reason a program should not simply write #1: a file number is only free if nothing else has it open, and nothing about the language stops two parts of one program each opening files. Asking for a free one is how they avoid colliding.

Kill(VBVariantValue)

MS-VBAL 6.1.2.5.2.4 Kill Deletes the files that match a pattern.

RuntimeSemanticsEvaluationResult Kill(VBVariantValue pathName)

Parameters

pathName VBVariantValue

The pattern: a file name, with wildcards, that can include a directory and a drive.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel): directories, and hidden or system files, are not deleted - Kill "*" leaves them; error 53 File not found when nothing matches, 55 when a match is open, 75 when one is read-only.

LOF(VBIntegerValue)

MS-VBAL 6.1.2.5.1.9 LOF Gets the length of an open file, in bytes, what has been written to it included.

RuntimeSemanticsEvaluationResult<VBLongValue> LOF(VBIntegerValue fileNumber)

Parameters

fileNumber VBIntegerValue

The file number.

Returns

RuntimeSemanticsEvaluationResult<VBLongValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Error 52 for a file number that is not open.

Loc(VBIntegerValue)

MS-VBAL 6.1.2.5.1.8 Loc Gets the current read/write position of a file.

RuntimeSemanticsEvaluationResult<VBLongValue> Loc(VBIntegerValue fileNumber)

Parameters

fileNumber VBIntegerValue

The file number.

Returns

RuntimeSemanticsEvaluationResult<VBLongValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel): for a file opened Random, the number of the last record read or written; Binary, the position of the last byte read or written - both 0 before either; for one opened for Input, the bytes read divided by 128, plus 1; for Output or Append, the bytes written divided by 128. Error 52 for a file number that is not open.

MkDir(VBStringValue)

MS-VBAL 6.1.2.5.2.5 MkDir Creates a directory.

RuntimeSemanticsEvaluationResult MkDir(VBStringValue path)

Parameters

path VBStringValue

The directory.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Error 75 Path/File access error when a directory or a file of the name exists, 76 Path not found when the directory it would be in does not (recorded in Excel).

RmDir(VBStringValue)

MS-VBAL 6.1.2.5.2.6 RmDir Removes an empty directory.

RuntimeSemanticsEvaluationResult RmDir(VBStringValue path)

Parameters

path VBStringValue

The directory.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

Error 75 Path/File access error for one that holds a file or a directory, 76 Path not found for one that does not exist - a file, or a pattern (recorded in Excel).

Seek(VBIntegerValue)

MS-VBAL 6.1.2.5.1.10 Seek Gets the position of the next read or write of a file: the next record of one opened Random, the next byte of any other, the first being 1.

RuntimeSemanticsEvaluationResult<VBLongValue> Seek(VBIntegerValue fileNumber)

Parameters

fileNumber VBIntegerValue

The file number.

Returns

RuntimeSemanticsEvaluationResult<VBLongValue>

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

For a file opened for Append, the bytes are counted from where the appending began, as MS-VBA counts them (recorded in Excel). Error 52 for a file number that is not open.

SetAttr(VBStringValue, VBFileAttribute)

MS-VBAL 6.1.2.5.2.7 SetAttr Sets the attributes of a file: exactly the ones given, so VBNormal clears them.

RuntimeSemanticsEvaluationResult SetAttr(VBStringValue pathName, VBFileAttribute attributes)

Parameters

pathName VBStringValue

The file's path.

attributes VBFileAttribute

The attributes.

Returns

RuntimeSemanticsEvaluationResult

A RuntimeSemanticsEvaluationResult object encapsulating the result of the successful operation, or the error metadata otherwise.

Remarks

As in MS-VBA (recorded in Excel): VBReadOnly, VBHidden, VBSystem and VBArchive only - any other is error 5; error 55 for a file open in any mode but Input, 53 for one that does not exist, 52 for a pattern.