| Package | com.hippohx |
| Class | public class File |
| Inheritance | File HaxeBackendListener flash.events.EventDispatcher |
Unless stated otherwise, you should be able to pass full or relative paths to most of the methods if this class. But please note that if you want to use paths with backslashes "\" you MUST escape them like this "\\".
| Method | Defined by | ||
|---|---|---|---|
|
File()
Do NOT call this constructor, please use getInstance method instead.
| File | ||
|
appendToFile(filePath:String, fileContent:String):void
Appends new content to a text file.
| File | ||
|
copyDirectory(source:String, destination:String):void
Copies a directory to the new destination.
| File | ||
|
copyFile(source:String, destination:String):void
Copies source file to destination file.
| File | ||
|
createDirectory(directoryPath:String):void
Creates a directory in the given path.
| File | ||
|
deleteDirectory(directoryPath:String):void
Deletes a directory.
| File | ||
|
deleteFile(filePath:String):void
Deletes a file.
| File | ||
|
fileExists(filePath:String):Boolean
Checks if a file exists.
| File | ||
|
fullPath(relPath:String):String
Given an item's relative path, it returns the full path to the item.
| File | ||
![]() |
getHaxeBackendId():String
Returns HAXE_BACKEND API identifier.
| HaxeBackendListener | |
|
[static]
Use this method to retrieve an instance of the class, do NOT call the constructor directly.
| File | ||
|
isDirectory(directoryPath:String):Boolean
Checks if a specific path is a directory or not.
| File | ||
|
isDirectoryEmpty(directoryPath:String):Boolean
Checks if a directory is empty.
| File | ||
|
openBrowserWindow(filePath:String):void
Opens a URL (either local or remote) in the default browser.
| File | ||
|
openFile(filePath:String, args:Array = null):void
Launches any file on the system with the default application.
| File | ||
|
readDirectory(directoryPath:String):Array
Reads a directory and returns an array of FileKind objects.
| File | ||
|
readFile(filePath:String):String
Reads the content of a text file.
| File | ||
|
renameFile(path:String, newName:String):String
Renames source file to new name.
| File | ||
|
search(path:String, regexp:String, regexpOptions:String = "", recursive:Boolean = false):Array
Searchs on a given path for folders and files matching a regular expression.
| File | ||
|
writefile(filePath:String, fileContent:String):void
Writes a text file to the system.
| File | ||
| File | () | constructor |
public function File()Do NOT call this constructor, please use getInstance method instead.
See also
| appendToFile | () | method |
public function appendToFile(filePath:String, fileContent:String):voidAppends new content to a text file.
Neko call is neko.io.File.append(filePath,false);.
ParametersfilePath:String — A string with the path to the file you want to append content to.
|
|
fileContent:String — A string with the content you want to append.
|
| copyDirectory | () | method |
public function copyDirectory(source:String, destination:String):voidCopies a directory to the new destination. The copy is recursive.
The destination directory is automatically created before making the copy, so it shoudn't exist before. If you want to copy "C:\Program Files\MyDir" to "C:\Program Files\MySecondDir", "MySecondDir" shouldn't exist previous to the call. Do it like this:
File.getInstance().createDirectory("C:\\Program Files\\MyDir","C:\\Program Files\\MySecondDir");
PLEASE note that currently there's a bug regarding this method: File.copyDirectory doesn't copy .svn folders.
Parameterssource:String — Directory to be copied.
|
|
destination:String — Destination directory. MUST NOT exist before the call, it's automatically created.
|
| copyFile | () | method |
public function copyFile(source:String, destination:String):voidCopies source file to destination file. If destination file exists, it will be overwritten.
Neko call is neko.io.File.copy(source,destination);.
Parameterssource:String — Path to the the original file.
|
|
destination:String — Path to the destination file.
|
| createDirectory | () | method |
public function createDirectory(directoryPath:String):voidCreates a directory in the given path. You have to include the name of the new directory in the path. So if you want to create a directory called "MyDir" on "C:\Program Files" you have to use something like:
File.getInstance().createDirectory("C:\\Program Files\\MyDir");
directoryPath:String — A String with the path of the directory you want to create.
|
| deleteDirectory | () | method |
public function deleteDirectory(directoryPath:String):voidDeletes a directory. The directory MUST be empty before deleting it.
ParametersdirectoryPath:String — The path of the directory to be deleted.
|
See also
| deleteFile | () | method |
public function deleteFile(filePath:String):voidDeletes a file.
Neko call is neko.FileSystem.deleteFile(filePath);.
ParametersfilePath:String — A String with the path to the file to be deleted.
|
| fileExists | () | method |
public function fileExists(filePath:String):BooleanChecks if a file exists.
Neko call is neko.FileSystem.exists(filePath);.
ParametersfilePath:String — A String with the path to the file to be checked.
|
Boolean — true if the file exists, false otherwise.
|
| fullPath | () | method |
public function fullPath(relPath:String):StringGiven an item's relative path, it returns the full path to the item.
ParametersrelPath:String — Relative path to an item (file or folder).
|
String — A String with the absolute path to the same item.
|
| getInstance | () | method |
public static function getInstance():FileUse this method to retrieve an instance of the class, do NOT call the constructor directly. Note that you don't need to store the instance to access its methods, you can simply do this:
var exists:Boolean = File.getInstance().fileExists(filePath);
File |
| isDirectory | () | method |
public function isDirectory(directoryPath:String):BooleanChecks if a specific path is a directory or not.
Neko call is neko.FileSystem.isDirectory(directoryPath);.
ParametersdirectoryPath:String — A String with the path you want to check.
|
Boolean — true if the path is directory, false otherwise.
|
| isDirectoryEmpty | () | method |
public function isDirectoryEmpty(directoryPath:String):BooleanChecks if a directory is empty. You might want to use this before trying to delete one, as currently directories can only be removed if empty.
ParametersdirectoryPath:String — A String with the path to the directory you want to check.
|
Boolean — true if there are no items on the directory, false otherwise.
|
See also
| openBrowserWindow | () | method |
public function openBrowserWindow(filePath:String):voidOpens a URL (either local or remote) in the default browser.
Neko call is systools.Browser.launch(filePath);.
ParametersfilePath:String — The path to the file, either full or relative.
|
| openFile | () | method |
public function openFile(filePath:String, args:Array = null):voidLaunches any file on the system with the default application.
Neko call is neko.Sys.command('"start" ' + filePath,args);.
ParametersfilePath:String — The path to the file, either full or relative.
|
|
args:Array (default = null) — Array of Strings that would be passed as parameters to the file opened.
|
| readDirectory | () | method |
public function readDirectory(directoryPath:String):ArrayReads a directory and returns an array of FileKind objects. Please note that this method will NOT return fullpaths, only the names of the items (files and folders) in it.
Neko call is neko.FileSystem.readDirectory(directoryPath); plus later creation of FileKind objects.
ParametersdirectoryPath:String — A String with the path of the directory you want to check.
|
Array — Array of FileKind objects.
|
See also
| readFile | () | method |
public function readFile(filePath:String):StringReads the content of a text file.
Neko call is neko.io.File.read(filePath,false);.
ParametersfilePath:String — A String with the path to the file to be read.
|
String — A String with the content of the file.
|
| renameFile | () | method |
public function renameFile(path:String, newName:String):StringRenames source file to new name. The new file will be created in the same folder as the original.
Neko call is neko.FileSystem.rename(path,newPath);.
Parameterspath:String — Path to the the original file. The new file will be created in the same folder as the original.
|
|
newName:String — Path to the the original file.
|
String — The full path to the new file.
|
| search | () | method |
public function search(path:String, regexp:String, regexpOptions:String = "", recursive:Boolean = false):ArraySearchs on a given path for folders and files matching a regular expression. See Regexp tutorial on haXe site for more info.
Parameterspath:String — Initial path.
|
|
regexp:String — Regular expression to match folders and file names. Please note that as opposed to haXe you don't have to start your expression with "~/" and end it with "/".
|
|
regexpOptions:String (default = "") — Options are "i" (case insensitive), "g" (global replace or split), "m" (multiline matching), "s" ("." will match also newlines). Pass them together as a single string, i.e. "mi" for multiline matching and case-insensitive.
|
|
recursive:Boolean (default = false) — When set to true the search will be extended to the folders inside the initial path. Think about performance when searching recursively.
|
Array — An Array of Strings with the paths to the files/folders that match the regular expression.
|
| writefile | () | method |
public function writefile(filePath:String, fileContent:String):voidWrites a text file to the system.
Neko call is neko.io.File.write(filePath,false);.
ParametersfilePath:String — A String with the path to the file to be written.
|
|
fileContent:String — A String with the content of the file.
|