FClose()
FCount()
FCreate()
FErase()
FError()
FieldBlock()
FieldName()
FieldPos()
FieldPut()
Changes the name of a specified file
Syntax
RENAME <cOldFile> TO <cNewFile>
Arguments
<cOldFile> Old filename
<cNewFile> New Filename
Description
This command changes the name of <cOldFile> to <cNewFile>. Both <cOldFile> and <cNewFile> must include a file extension. This command if not affected by the SET PATH TO or SET DEFAULT TO commands; drive and directory designates must be specified if either file is in a directory other then the default drive and directory.
If <cNewFile> id currently open or if it previously exists, this command will not perform the desired operation.
Examples
RENAME hello.txt TO hello.old
Compliance
Clipper
Files
Library is rtl
Seealso
CURDIR(), ERASE, FILE(), FERASE(), FRENAME()
Renames a file by low-level access
Syntax
FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess
Arguments
<cOldFile> Old filename to be changed
<cNewFile> New filename
Returns
<nSuccess> If successful, a 0 will be returned otherwise, a -1 will be returned.
Description
This function renames the specified file <cOldFile> to <cNewFile>. A filename and/or directory name may be specified for either parameter. However, if a path is supplied as part of <cNewFile> and this path is different from either the path specified in <cOldFile> or (if none is used) the current drive and directory, the function will not execute successfully.
Neither parameter is subject to the control of the SET PATH TO or SET DEFAULT TO commands. In attempting to locate the file to be renamed, this function will search the default drive and directory or the drive and path specified in <cOldFile>. It will not search directories named by the SET PATH TO and SET DEFAULT TO commands or by the DOS PATH statement.
If the file specified in <cNewFile> exists or the file is open, the function will be unable to rename the file. If the function is unable to complete its operation, it will return a value of -1. If it is able to rename the file, the return value for the function will be 0. A call to FERROR() function will give additional infor- mation about any error found.
Examples
#include "fileio.ch" nResult := FRename( "x.txt", "x1.txt" ) IF nResult == F_ERROR ? "File could not be renamed." ENDIF
Compliance
Clipper
Files
Library is rtl
Seealso
Erase any file from disk by low-level access
Syntax
FERASE( <cFile> ) --> nSuccess
Arguments
<cFile> Name of file to erase.
Returns
<nSuccess> 0 if successful, -1 if not
Description
This function deletes the file specified in <cFile> from the disk. No extensions are assumed. The drive and path my be included in <cFile>; neither the SET DEFAULT not the SET PATH command controls the performance of this function. If the drive or path is not used, the function will look for the file only on the currently selected directory on the logged drive.
If the function is able to successfully delete the file from the disk, the value of the function will be 0; otherwise a -1 will be returned. If not successfull, additional information may be obtained by calling the FERROR() function.
Note: Any file to be removed by FERASE() must still be closed.
Examples
#include "fileio.ch" IF FErase( "test.txt" ) != F_ERROR ? "File successfully erased" ELSE ? "File can not be deleted" ENDIF
Compliance
Clipper
Files
Library is rtl
Seealso
Copies a file.
Syntax
COPY FILE <cfile> TO <cfile1>
Arguments
<cFile> Filename of source file <cFile1> Filename of target file
Description
This command makes an exact copy of <cFile> and names it <cFile1>. Both files must have the file extension included; the drive and the directory names must also be specified if they are different from the default drive and/or director. <cFile1> also can refer to a OS device (e.g. LPT1). This command does not observe the SET PATH TO or SET DEFAULT TO settings.
Examples
COPY FILE C:\harbour\tests\adirtest.prg TO C:\temp\adirtest.prg COPY FILE C:\harbour\utils\hbdoc\gennf.prg TO LPT1
Compliance
Clipper
Seealso
ERASE, RENAME, FRENAME(), FERASE()
FRENAME() Change the name of a file ------------------------------------------------------------------------------ Syntax FRENAME(<cOldFile>, <cNewFile>) --> nSuccess Arguments <cOldFile> is the name of the file to be renamed, including the file extension. A drive letter and/or path name may also be included as part of the file name. <cNewFile> is the new name of the file, including the file extension. A drive letter and/or path name may also be included as part of the name. Returns FRENAME() returns -1 if the operation fails and zero if it succeeds. In the case of a failure, FERROR() can be used to determine the nature of the error. Description FRENAME() is a file function that changes the name of a specified file to a new name and is identical to the RENAME command. When FRENAME() is called, <cOldFile> is renamed only if it is located in the current DOS directory or in the specified path. FRENAME() does not use SET DEFAULT or SET PATH to locate <cOldFile>. If the source directory is different from the target directory, the file moves to the target directory. In the instance that either <cNewFile> exists or is currently open, FRENAME() fails and returns -1, indicating that it did not perform its designated action. The nature of the error can be determined with FERROR(). Warning! Files must be CLOSEd before renaming. Attempting to rename an open file will produce unpredictable results. When a database file is renamed, the associated memo (.dbt) file must also be renamed. Failure to do so may compromise the integrity of your databases. Examples . This example demonstrates a file rename: IF FRENAME("OldFile.txt", "NewFile.txt") == -1 ? "File error:", FERROR() ENDIF Files Library is CLIPPER.LIB.
See Also: CLOSE ERASE FERASE() FERROR() FILE() RENAME
Fill a series of arrays with directory information
ADIR( [ <cFilespec> ], [ <aFilenames> ], [ <aSizes> ], [ <aDates> ], [ <aTimes> ], [ <aAttributes> ] ) --> nFiles
Close a specific set of files
CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]
Copy a file to a new file
COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>
Return the current DOS directory
CURDIR( [ <cDrivespec> ] ) --> cDirectory
Remove a file from disk
DELETE FILE | ERASE <xcFile>
Display a listing of files from a specified path
DIR [ <xcFileSpec> ]
Change the current DOS directory
DIRCHANGE(<cDir>) --> nSuccess
Create an array of directory and file information
DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory
Create a directory
DIRMAKE(<cNewDir>) --> nSuccess
Remove a directory
DIRREMOVE(<cDirName>) --> nSuccess
Change the current DOS disk drive
DISKCHANGE(<cDrive>) --> lSuccess
Return the current DOS drive
DISKNAME() --> cDrive
Return the space available on a specified disk
DISKSPACE( [ <nDrive> ] ) --> nBytes
Remove a file from disk
ERASE | DELETE FILE <xcFile>
Determine if files exist in the default directory or path
FILE( <cFilespec> ) --> lExists
Change the name of a file
RENAME <xcOldFile> TO <xcNewFile>
Echo console output to a text file
SET ALTERNATE TO [ <xcFile> [ADDITIVE]] SET ALTERNATE on | OFF | <xlToggle>
Set the CA-Clipper default drive and directory
SET DEFAULT TO [ <xcPathspec> ]
Specify the CA-Clipper search path for opening files
SET PATH TO [ <xcPathspec list> ]
Display the contents of a text file
TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]
Close an open binary file and write DOS buffers to disk
FCLOSE( <nHandle> ) --> lError
Create and/or truncate a binary file to zero length
FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle
Delete a file from disk
FERASE( <cFile> ) --> nSuccess
Test for errors after a binary file operation
FERROR() --> nErrorCode
Open a binary file
FOPEN( <cFile>, [ <nMode> ] ) --> nHandle
Read characters from a binary file into a buffer variable
FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes
Read characters from a binary file
FREADSTR( <nHandle>, <nBytes> ) --> cString
Change the name of a file
FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess
Set a binary file pointer to a new position
FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition
Write to an open binary file
FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] ) --> nBytesWritten
Return the current database file header length
HEADER() --> nBytes