FileIO Library API - brombres/Rogue GitHub Wiki
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( filepath:String ) | File | |
| operator+( left:File, right:File ) | File | |
| operator+( left:File, right:String ) | File | |
| operator+( left:String, right:File ) | File |
| Name | Type | Description |
|---|---|---|
| filepath | String |
| Signature | Return Type | Description |
|---|---|---|
| abs() | File | |
| appending( suffix:String ) | File | "filename.png".appending("@2x") -> "[email protected]" "filename.png".appending(null) -> "filename.png" |
| character_writer() | CharacterToUTF8ByteWriter | |
| common_folder( other:File ) | File | |
| contains_wildcards() | Logical | |
| contains( pattern:FilePattern ) | Logical | Returns true if this folder contains a file with the given pattern. |
| conventional_filepath() | String | |
| copy_to( destination:File, &if_different, &if_newer, &dry_run, &verbose, &ignore_hidden ) | Int? | Copies a file or the contents of a folder to a specified file or folder. Returns the count of files copied or null on an error. |
| crc32() | Int32 | |
| create_folder() | Logical | Creates the specified folder along with intermediate folders if necessary. Returns 'true' on success or if the filepath already exists as a folder. Returns 'false' on failure to |
| delete() | Logical | |
| description() | String | |
| esc() | String | |
| exists() | Logical | |
| extension() | String | |
| filename() | String | |
| filepath_before_wildcards() | String | Example: alpha/beta/image*.png -> alpha/beta |
| folder() | String | |
| folder_before_wildcards() | String | Example: alpha/beta/image*.png -> alpha/beta |
| has_parent() | Logical | |
| hashcode() | Int | |
| is_absolute() | Logical | |
| is_folder() | Logical | |
| is_hidden() | Logical | |
| is_valid_utf8() | Logical | |
| is_different_than( other:File ) | Logical | Returns false if 'this' and 'other' both exist, are the same size, and contain the same bytes. |
| is_newer_than( other:File ) | Logical | |
| is_valid_filename_character( ch:Character, &any_os ) | Logical | |
| listing( [filepattern=null:FilePattern?], &ignore_hidden, &absolute, &omit_path, &files, &folders, &unsorted, &recursive ) | String[] | Use the filepattern '**' for a recursive listing. |
| listing( pattern:String, &ignore_hidden, &absolute, &omit_path, &files, &folders, &unsorted, &recursive ) | String[] | |
| load_as_bytes( &discard_bom ) | Byte[] |
discard_bom Discard the Byte Order Marker, if it exists. |
| load_as_string( [encoding=StringEncoding.AUTODETECT:StringEncoding] ) | String | |
| matches( pattern:FilePattern, &ignore_case ) | Logical | |
| operator/( other:File ) | File | |
| operator/( other_filepath:String ) | File | |
| operator/( pattern:FilePattern ) | File | |
| operator<>( other:File ) | Int | |
| operator==( other:File ) | Logical | |
| parent( [level=1:Int32] ) | File | |
| print_to( buffer:PrintWriter ) | ||
| print_writer( &append ) | PrintWriter | |
| reader() | FileReader | |
| relative_to( base_folder:File ) | File | |
| rename( destination:File ) | Logical | |
| resolved() | File | |
| save( data:Byte[] ) | Logical | |
| save( data:String, &bom ) | Logical | |
| separator() | Character | |
| size() | Int64 | |
| split_filepath_and_extension() | (filepath:String,extension:String) | |
| symlink( target:File ) | Symlinks this File to the target file. Unix-style example: File("/usr/local/bin/cmdlauncher").symlink(File("/opt/myapp/bin/cmd")) | |
| timestamp() | Timestamp | |
| timestamp_ms() | Int64 | Returns the last modified time. |
| to<<Object>>() | Boxed<<File>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| touch() | ||
| type_info() | TypeInfo | |
| with_destination( destination:File ) | File |
Uses console-style filename and folder rules to modify a source filepath given a destination filepath. File( "folder1/filename1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "folder1/filename1" ).with_destination( File("folder2") ) -> "folder2/filename1" File( "folder1/filename1" ).with_destination( File("filename2") ) -> "filename2" File( "filename1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "filename1" ).with_destination( File("folder2") ) -> "folder2/filename1" File( "filename1" ).with_destination( File("filename2") ) -> "filename2" File( "folder1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "folder1" ).with_destination( File("folder2") ) -> "folder2/folder1" File( "folder1" ).with_destination( File("filename2") ) -> "filename2" (folder1 renamed to filename2) Definitions - path: .exists and .is_folder - filename: not .exists or (.exists and not .is_folder) |
| with_extension( ext:String ) | File |
if ext is null or "": Removes any current ".extension". else Removes any current ".extension" and adds ".$"(ext). |
| without_extension() | File | |
| without_trailing_separator() | File | Removes trailing slash on anything except "/" |
| writer( &append ) | FileWriter |
extends Object
incorporates Reader<<$DataType>>
| Signature | Return Type | Description |
|---|---|---|
| stderr() | FDReader | |
| stdin() | FDReader |
| Name | Type | Description |
|---|---|---|
| auto_close | Logical | |
| buffer | Byte[] | |
| buffer_position | Int | |
| fd | Int | |
| position | Int |
| Signature | Return Type | Description |
|---|---|---|
| init( fd:Int, [auto_close=true:Logical] ) | ||
| buffer_more() | Logical | Used by Process which needs to keep buffering from both the stdout and stderr of a process to make sure the process doesn't get blocked. |
| close() | ||
| has_another() | Logical | |
| is_open() | Logical | |
| on_cleanup() | ||
| on_end_use() | ||
| on_use() | FDReader | |
| peek() | Byte | |
| position() | Int | |
| read() | Byte | |
| read( buffer:Byte[], limit:Int ) | Int | |
| reset() | ||
| seek( pos:Int ) | ||
| skip( n:Int ) | ||
| to<<Byte[]>>() | Byte[] | |
| to<<String>>() | String |
extends Object
incorporates Writer<<$DataType>>
| Signature | Return Type | Description |
|---|---|---|
| stdout() | FDWriter |
| Name | Type | Description |
|---|---|---|
| auto_close | Logical | |
| buffer | Byte[] | |
| error | Logical | |
| fd | Int | |
| position | Int |
| Signature | Return Type | Description |
|---|---|---|
| init( fd:Int, [auto_close=true:Logical] ) | ||
| close() | ||
| flush() | ||
| on_cleanup() | ||
| on_use() | FDWriter | |
| on_end_use( err:Exception ) | Exception | |
| position() | Int | |
| reset() | ||
| seek_end() | ||
| seek( pos:Int ) | ||
| skip( n:Int ) | ||
| write( bytes:Byte[] ) | ||
| write( ch:Byte ) | ||
| write( text:String ) |
extends Object
| Name | Type | Description |
|---|---|---|
| callback | Function(String) | |
| empty_segments | String[] | |
| filepath_segments | String[] | |
| filepaths | String[] | |
| options | FileListingOption | |
| path_segments | String[] | |
| pattern | FilePattern | |
| pattern_segments | String[] |
| Signature | Return Type | Description |
|---|---|---|
| init( folder_or_filepath:File, _pattern:FilePattern?, options:FileListingOption ) | ||
| collect( filename:String ) | ||
| fix( pattern:String ) | String | Without this fix, "**Alpha*" would not match "Source/Alpha.rogue" |
incorporates CommonCompoundMethods
| Category | Value | Description |
|---|---|---|
| ABSOLUTE | 1 | |
| FILES | 2 | |
| FOLDERS | 4 | |
| IGNORE_HIDDEN | 8 | |
| OMIT_PATH | 16 | |
| RECURSIVE | 32 | |
| UNSORTED | 64 |
| Name | Type | Description |
|---|---|---|
| categories | FileListingOption[] |
| Signature | Return Type | Description |
|---|---|---|
| create( name:String ) | FileListingOption | |
| create( value:Int ) | FileListingOption |
| Name | Type | Description |
|---|---|---|
| value | Int |
| Signature | Return Type | Description |
|---|---|---|
| absolute() | Logical | |
| description() | String | |
| files() | Logical | |
| folders() | Logical | |
| hashcode() | Int | |
| ignore_hidden() | Logical | |
| name() | String | |
| omit_path() | Logical | |
| operator!() | FileListingOption | |
| operator?() | Logical | |
| operator&( flag:FileListingOption ) | FileListingOption | |
| operator==( other:FileListingOption ) | Logical | |
| operator|( flag:FileListingOption ) | FileListingOption | |
| print_to( buffer:PrintWriter ) | ||
| recursive() | Logical | |
| set_absolute( setting:Logical ) | ||
| set_files( setting:Logical ) | ||
| set_folders( setting:Logical ) | ||
| set_ignore_hidden( setting:Logical ) | ||
| set_omit_path( setting:Logical ) | ||
| set_recursive( setting:Logical ) | ||
| set_unsorted( setting:Logical ) | ||
| to<<Int>>() | Int | |
| to<<Object>>() | Object | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo | |
| unsorted() | Logical |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( pattern:String ) | FilePattern |
| Name | Type | Description |
|---|---|---|
| pattern | String |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| matches( filepath:String, &ignore_case ) | Logical |
Determines whether or not the given filepath matches the given semi-Unix/Dos-style 'wildcard pattern'. 'pattern' is a regular text string that may contain the following special characters: * - Matches any number of characters but does not match '/' ** - Matches any number of characters including slashes ***/ - Matches any number of characters and a slash or else nothing. ? - Matches any one character except '/' Note: A filepath with a ./ prefix is checked with and without the prefix. |
| operator==( other:FilePattern ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<FilePattern>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends FileReader
| Name | Type | Description |
|---|---|---|
| @native13 | RogueCNativeProperty | |
| buffer | Byte[] | |
| buffer_position | Int | |
| count | Int | |
| error | Logical | |
| filepath | String | |
| position | Int |
| Signature | Return Type | Description |
|---|---|---|
| init( filepath:String ) | ||
| close() | ||
| fp() | Int64 | |
| open( filepath:String ) | Logical | |
| peek() | Byte | |
| read( result:Byte[], limit:Int ) | Int | |
| reset() | ||
| seek( pos:Int ) |
extends Object
incorporates Reader<<$DataType>>
| Signature | Return Type | Description |
|---|---|---|
| create( filepath:String ) | FileReader |
| Name | Type | Description |
|---|---|---|
| buffer | Byte[] | |
| buffer_position | Int | |
| count | Int | |
| error | Logical | |
| filepath | String | |
| position | Int |
| Signature | Return Type | Description |
|---|---|---|
| close() | ||
| has_another() | Logical | |
| on_cleanup() | ||
| on_end_use() | ||
| on_use() | FileReader | |
| on_end_use( this_reader:FileReader ) | ||
| open( filepath:String ) | Logical | |
| peek() | Byte | |
| position() | Int | |
| read() | Byte | |
| read( result:Byte[], limit:Int ) | Int | |
| remaining() | Int | |
| reset() | ||
| seek( pos:Int ) | ||
| skip( n:Int ) | ||
| to<<Byte[]>>() | Byte[] | |
| to<<String>>() | String |
extends Object
| Name | Type | Description |
|---|---|---|
| base_folder | String | |
| filepath_set | [String:String] |
| Signature | Return Type | Description |
|---|---|---|
| init( base_folder:File, pattern:FilePattern, &ignore_hidden=true, &include_folders ) | ||
| init( base_folder:File, pattern:String, &ignore_hidden=true, &include_folders ) | ||
| init( base_folder:String, &allow_pattern=true, &include_folders ) | ||
| init( base_folder:String, pattern:FilePattern, &ignore_hidden=true, &include_folders ) | ||
| init( base_folder:String, pattern:String, &ignore_hidden=true, &include_folders ) | ||
| add( pattern:FilePattern, &ignore_hidden=true, &include_folders ) | ||
| add( pattern:String, &ignore_hidden=true, &include_folders ) | ||
| any_newer_than( filepath:String ) | Logical | |
| contains( file:File ) | Logical | |
| contains( filepath:String ) | Logical | |
| copy_to( to_folder:File, &if_newer, &if_different, &verbose, &dry_run ) | ||
| count() | Int | |
| delete( &verbose, &dry_run ) | ||
| filepaths() | TableValuesIterator<<String,String>> | |
| files() | File[] | |
| get( index:Int ) | String | |
| newest_timestamp_ms() | Int64? | |
| oldest_timestamp() | Int64? | |
| relative_filepaths() | String[] | |
| relative_files() | File[] | |
| relative_filepath( filepath:String ) | String | |
| remove( files:Files ) | Removes files from this listing but not from the filesystem - use delete() for that. | |
| remove( pattern:FilePattern ) | Removes files from this listing but not from the filesystem - use delete() for that. | |
| remove( pattern:String ) | Removes files from this listing but not from the filesystem - use delete() for that. | |
| remove( query:Function(String)->Logical ) | Removes files from this listing but not from the filesystem - use delete() for that. | |
| sync_to( dest_folder:File, &verbose, &keep_unused, &dry_run, &missing_only, &if_newer ) | Int | If 'if_newer' is not specified then files are copied if they are different. |
| to<<File[]>>() | File[] | |
| to<<String>>() | String | |
| to<<String[]>>() | String[] |
extends Object
incorporates Writer<<$DataType>>
| Name | Type | Description |
|---|---|---|
| @native5 | RogueCNativeProperty | |
| buffer | Byte[] | |
| error | Logical | |
| filepath | String | |
| position | Int |
| Signature | Return Type | Description |
|---|---|---|
| init() | ||
| init( _filepath:String, [append=false:Logical] ) | ||
| close() | ||
| flush() | ||
| fp() | Int64 | |
| on_cleanup() | ||
| on_use() | FileWriter | |
| on_end_use( err:Exception ) | Exception | |
| on_end_use( this_writer:FileWriter ) | ||
| open( filepath:String, [append=false:Logical] ) | Logical | |
| position() | Int | |
| reset() | ||
| seek_end() | ||
| seek( pos:Int ) | ||
| skip( n:Int ) | ||
| write( bytes:Byte[] ) | ||
| write( ch:Byte ) | ||
| write( data:String ) |
extends Object
| Name | Type | Description |
|---|---|---|
| fd | Int | |
| file | File |
| Signature | Return Type | Description |
|---|---|---|
| init( file:File ) | ||
| init( filepath:String ) | ||
| on_use() | MutexFile | |
| on_end_use( THISOBJ:MutexFile ) |