User Tools

Site Tools


file

File

The Qt documentation in C++ of this class (QFile) can be read here: http://doc.trolltech.com/4.4/qfile.html, http://doc.trolltech.com/4.4/qfileinfo.html, http://doc.trolltech.com/4.4/qtextstream.html

It is useful to use the files.

Implemented since KBasic V1.76.

Normally, KBasic uses UTF-8 to load and save text files.

STATIC METHODS

Size

Static Function Size(FileName As String) As Long


Resize

Static Function Resize(FileName As String, NewSize As Long) As Boolean


Truncate

Static Function Truncate(FileName As String) As Boolean


(SetReadable)

Sorry. Not supported yet.

Static Function SetReadable(FileName As String, Readable As Boolean, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

(SetWritable)

Sorry. Not supported yet.

Static Function SetWritable(FileName As String, Writable As Boolean, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

(SetExecutable)

Sorry. Not supported yet.

Static Function SetExecutable(FileName As String, Executable As Boolean, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

ReadText

Static Function ReadText(FileName As String, Codec As String = “UTF-8”, AutoDetectUnicode As Boolean = True, GenerateByteOrderMark As Boolean = True) As String

FileName might be any existing file or stderr, stdin, stdout.

Codec might be any value listed on http://doc.trolltech.com/4.4/qtextcodec.html#details

Commonly used is UTF-8, UTF-16 or UTF-32. Normally, choosing UTF-8 will be sufficient.

Reads the entire file into a string.

WriteText

Static Function WriteText(FileName As String, Text As String, Append As Boolean = False, Codec As String = “UTF-8”, AutoDetectUnicode As Boolean = True, GenerateByteOrderMark As Boolean = True) As Boolean

FileName might be any existing file or stderr, stdin, stdout.

Codec might be any value listed on http://doc.trolltech.com/4.4/qtextcodec.html#details

Commonly used is UTF-8, UTF-16 or UTF-32. Normally, choosing UTF-8 will be sufficient.

Erases previous existing contents of file. If you need to append to the file read the contents with ReadText, append the new string and write it back with WriteText.

If you need ASCII-Code use ReadBinary and WriteBinary or use the following code snippset:

File.WriteText(strFln, strASCII, False, "ISO 8859-1", False, False)

ReadBinary

Static Function ReadBinary(FileName As String) As String

FileName might be any existing file or stderr, stdin, stdout.

Reads the entire file into memory.

WriteBinary

Static Function WriteBinary(FileName As String, Binary As String, Append As Boolean = False) As Boolean

FileName might be any existing file or stderr, stdin, stdout.

Erases previous existing contents of file. If you need to append to the file read the contents with ReadBinary, append the new data and write it back with WriteBinary.

Static Function Link(SourceFileName As String, DestinationFileName As String) As Boolean


Create

Static Function Create(FileName As String) As Boolean


Remove

Static Function Remove(FileName As String) As Boolean


Copy

Static Function Copy(SourceFileName As String, DestinationFileName As String, Overwrite As Boolean = True) As Boolean


Move

Static Function Move(SourceFileName As String, DestinationFileName As String, Overwrite As Boolean = True) As Boolean


Rename

Static Function Rename(SourceFileName As String, DestinationFileName As String) As Boolean


Exists

Static Function Exists(FileName As String) As Boolean


DateTimeCreatedAsString

Static Function DateTimeCreatedAsString(FileName As String) As String


DateTimeUpdatedAsString

Static Function DateTimeUpdatedAsString(FileName As String) As String

Returns the last modification time of the contents of a file.


DateTimeReadAsString

Static Function DateTimeReadAsString(FileName As String) As String

Returns the last access time of a file.


Owner

Static Function Owner(FileName As String) As String


Group

Static Function Group(FileName As String) As String


IsReadable

Static Function IsReadable(FileName As String, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

IsWritable

Static Function IsWritable(FileName As String, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

IsExecutable

Static Function IsExecutable(FileName As String, Who As String = “User”) As Boolean

Possible values for Who are

  • User
  • Owner
  • Group
  • Other

IsHidden

Static Function IsHidden(FileName As String) As Boolean


IsFile

Static Function IsFile(FileName As String) As Boolean


WithNativeSeparators

Static Function WithNativeSeparators(FileName As String) As String


WithoutNativeSeparators

Static Function WithoutNativeSeparators(FileName As String) As String


SymLinkTarget

Static Function SymLinkTarget(FileName As String) As String


Name

Static Function Name(FileName As String) As String


Path

Static Function Path (FileName As String) As String


Suffix

Static Function Suffix(FileName As String) As String


IsRelative

Static Function IsRelative(FileName As String) As Boolean


Static Function IsSymLink(FileName As String) As Boolean


file.txt · Last modified: 2013/04/09 22:57 (external edit)