cFile


Index:
Articles
Classes
Hooks

Quick navigation:
BannerPattern
BossBarColor
BossBarDivisionType
cArrowEntity
cBeaconEntity
cBedEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoat
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cColor
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEnderCrystal
cEntity
cEntityEffect
cExpBottleEntity
cExpOrb
cFallingBlock
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLeashKnot
cLineBlockTracer
cLuaWindow
cMap
cMapManager
cMobHeadEntity
cMobSpawnerEntity
cMojangAPI
cMonster
cNetwork
cNoteEntity
cObjective
cPainting
cPawn
cPickup
cPlayer
cPlugin
cPluginLua
cPluginManager
cProjectileEntity
cRankManager
cRoot
cScoreboard
cServer
cServerHandle
cSignEntity
cSplashPotionEntity
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cUDPEndpoint
cUrlClient
cUrlParser
CustomStatistic
cUUID
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
EffectID
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
SmokeDirection
sqlite3
StatisticsManager
TakeDamageInfo
tolua
Vector3d
Vector3f
Vector3i
Globals

Contents


cFile class

Provides helper functions for manipulating and querying the filesystem. Most functions are static, so they should be called directly on the cFile class itself:

cFile:DeleteFile("/usr/bin/virus.exe");


Functions

NameParametersReturn valueNotes
ChangeFileExt
FileNamestring
NewExtstring
string
(STATIC) Returns FileName with its extension changed to NewExt. NewExt may begin with a dot, but needn't, the result is the same in both cases (the first dot, if present, is ignored). FileName may contain path elements, extension is recognized as the last dot after the last path separator in the string.
Copy
SrcFileNamestring
DstFileNamestring
IsSuccessboolean
(STATIC) Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists.
CreateFolder
FolderPathstring
IsSuccessboolean
(STATIC) Creates a new folder. Returns true if successful. Only a single level can be created at a time, use CreateFolderRecursive() to create multiple levels of folders at once.
CreateFolderRecursive
FolderPathstring
IsSuccessboolean
(STATIC) Creates a new folder, creating its parents if needed. Returns true if successful.
Delete
Pathstring
IsSuccessboolean
(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty.
NOTE: If you already know if the object is a file or folder, use DeleteFile() or DeleteFolder() explicitly.
DeleteFile
FilePathstring
IsSuccessboolean
(STATIC) Deletes the specified file. Returns true if successful.
DeleteFolder
FolderPathstring
IsSuccessboolean
(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty.
DeleteFolderContents
FolderPathstring
IsSuccessboolean
(STATIC) Deletes everything from the specified folder, recursively. The specified folder stays intact. Returns true if successful.
Exists
Pathstring
Existsboolean
(STATIC) Returns true if the specified file or folder exists.
OBSOLETE, use IsFile() or IsFolder() instead
GetExecutableExt
string
(STATIC) Returns the customary executable extension (including the dot) used by the current platform (".exe" on Windows, empty string on Linux).
GetFolderContents
FolderNamestring
table
(STATIC) Returns the contents of the specified folder, as an array table of strings. Each filesystem object is listed. Use the IsFile() and IsFolder() functions to determine the object type. Note that "." and ".." are NOT returned. The order of the names is arbitrary (as returned by OS, no sorting).
GetLastModificationTime
Pathstring
number
(STATIC) Returns the last modification time (in current timezone) of the specified file or folder. Returns zero if file not found / not accessible. The returned value is in the same units as values returned by os.time().
GetPathSeparator
string
(STATIC) Returns the primary path separator used by the current platform. Returns "\" on Windows and "/" on Linux. Note that the platform or CRT may support additional path separators, those are not reported.
GetSize
FileNamestring
number
(STATIC) Returns the size of the file, or -1 on failure.
IsFile
Pathstring
boolean
(STATIC) Returns true if the specified path points to an existing file.
IsFolder
Pathstring
boolean
(STATIC) Returns true if the specified path points to an existing folder.
ReadWholeFile
FileNamestring
string
(STATIC) Returns the entire contents of the specified file. Returns an empty string if the file cannot be opened.
Rename
OrigPathstring
NewPathstring
IsSuccessboolean
(STATIC) Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists.
Generated by APIDump on 2024-12-21 00:43:56, Build ID 104, Commit b92dc1cda3576ffc4c85347b0e8449d5adb87ef6