Outils pour utilisateurs

Outils du site


fr:code:data:file

Ceci est une ancienne révision du document !


File [En cours de Traduction Wismerheal][WSL]

L'objet Fichier vous permet de lire et écrire un fichier.

Fonctions

File

Fonction de construction.

Syntaxe

var myObject = new File();

Example

Créer l'objet Fichier.

var myObject = new File();

copy

Copier un fichier.

Syntaxe

File.copy(source, destination);
File.copy(source, destination, options);

Arguments

  1. source - (string) la source du fichier à copier
  2. destination - (string) la destination fichier/dossier
  3. options - (object) [Ajouté dans Actionaz 3.0.1.]
    • noErrorDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait si une erreur est rencontrée ?(Windows seulement, défaut: vrai)
    • noConfirmDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait si une confirmation est requise ? (Windows seulement, défaut: vrai)
    • noProgressDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait en cours de progression (Windows seulement, défaut: vrai)
    • createDestinationDirectory - (bool) le chemin de destination devrait-il être créé s'il n'existe pas ? (Linux seulement, défaut: vrai)

Renvoie

  • (null) rien

Exceptions

  • (ParameterCountError) paramètre de compteur incorrect
  • (DirectoryCreationError) impossible de créer le dossier de destination (Linux seulement)
  • (DirectoryDoesntExistError) le dossier de destination n'existe pas (Linux seulement)
  • (CopyError) copie échouée
  • (CopyAbortedError) copie annulée (Windows seulement)

move

Déplace un fichier.

Syntaxe

File.move(source, destination);
File.move(source, destination, options);

Arguments

  1. source - (string) la source du fichier à déplcer
  2. destination - (string) la destination du fichier/dossier
  3. options - (object) [Ajouté dans Actionaz 3.0.1.]
    • noErrorDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait si une erreur est rencontrée ?(Windows seulement, défaut: vrai)
    • noConfirmDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait si une confirmation est requise ? (Windows seulement, défaut: vrai)
    • noProgressDialog - (bool) devrait-il y avoir une fenêtre de dialogue qui apparait en cours de progression (Windows seulement, défaut: vrai)
    • createDestinationDirectory - (bool) le chemin de destination devrait-il être créé s'il n'existe pas ? (Linux seulement, défaut: vrai)

Returns

  • (null) nothing

Exceptions

  • (ParameterCountError) incorrect parameter count
  • (DirectoryCreationError) unable to create the destination directory (Linux only)
  • (DirectoryDoesntExistError) the destination directory doesn't exist (Linux only)
  • (MoveError) move failed
  • (MoveAbortedError) move aborted (Windows only)

rename

This function is an alias of the move function.

remove

Remove a file.

Syntax

File.remove(filename);
File.remove(filename, options);

Arguments

  1. filename - (string) the file to remove
  2. options - (object) [Added in Actionaz 3.0.1.]
    • noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true)
    • noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true)
    • noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true)
    • allowUndo - (bool) should the file/directory be moved to the trash bin (Windows only, default: false)

Returns

  • (null) nothing

Exceptions

  • (ParameterCountError) incorrect parameter count
  • (RemoveError) remove failed
  • (RemoveAbortedError) remove aborted (Windows only)

Methods

open

Opens a file.

Syntax

myObject.open(filename, openMode);

Arguments

  1. filename - (string) the filename of the file to open
  2. openMode - (OpenMode) the open mode

Returns

  • (File) this File

Exceptions

  • (CannotOpenFileError) cannot open the file

write

Write raw data to this File.

Syntax

myObject.write(data);
myObject.write(other);

Arguments

  1. data - (RawData) the data to write
  2. other - (mixed) the data to write

Returns

  • (File) this File

Exceptions

  • (WriteFailedError) write failed

writeText

Write text to this File.

Syntax

myObject.writeText(text);
myObject.writeText(text, encoding);

Arguments

  1. text - (string) the text to write
  2. encoding - (Encoding) the encoding to use

Returns

  • (File) this File

Exceptions

  • (WriteFailedError) write failed

read

Read raw data from this File.

Syntax

myObject.read();

Returns

  • (RawData) the raw data read from the file

readText

Read text from this File.

Syntax

myObject.readText();
myObject.readText(encoding);

Arguments

  1. encoding - (Encoding) the encoding to use

Returns

  • (string) the text read from the file

close

Close this file.

Syntax

myObject.close();

Returns

  • (File) this File

copy

Copy this file to another location.

Syntax

myObject.copy(destination);
myObject.copy(destination, options);

Arguments

  1. destination - (string) the location where to copy the file
  2. options - (object) [Added in Actionaz 3.0.1.]
    • noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true)
    • noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true)
    • noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true)
    • createDestinationDirectory - (bool) should the destination directory be created if it doesn't exist (Linux only, default: true)

Returns

  • (File) this File

Exceptions

  • (ParameterCountError) incorrect parameter count
  • (DirectoryCreationError) unable to create the destination directory (Linux only)
  • (DirectoryDoesntExistError) the destination directory doesn't exist (Linux only)
  • (CopyError) copy failed
  • (CopyAbortedError) copy aborted (Windows only)

move

Move this file to another location.

Syntax

myObject.move(destination);
myObject.move(destination, options);

Arguments

  1. destination - (string) the location where to move the file
  2. options - (object) [Added in Actionaz 3.0.1.]
    • noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true)
    • noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true)
    • noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true)
    • createDestinationDirectory - (bool) should the destination directory be created if it doesn't exist (Linux only, default: true)

Returns

  • (File) this File

Exceptions

  • (ParameterCountError) incorrect parameter count
  • (DirectoryCreationError) unable to create the destination directory (Linux only)
  • (DirectoryDoesntExistError) the destination directory doesn't exist (Linux only)
  • (MoveError) move failed
  • (MoveAbortedError) move aborted (Windows only)

rename

This method is an alias of the move method.

remove

Remove this file.

Syntax

myObject.remove();
myObject.remove(options);

Arguments

  1. options - (object) [Added in Actionaz 3.0.1.]
    • noErrorDialog - (bool) should an error dialog be shown if an error occurs (Windows only, default: true)
    • noConfirmDialog - (bool) should a confirmation dialog be shown if needed (Windows only, default: true)
    • noProgressDialog - (bool) should a progress dialog be shown (Windows only, default: true)
    • allowUndo - (bool) should the file/directory be moved to the trash bin (Windows only, default: false)

Returns

  • (File) this File

Exceptions

  • (ParameterCountError) incorrect parameter count
  • (RemoveError) remove failed
  • (RemoveAbortedError) remove aborted (Windows only)

Enumerations

OpenMode

File open mode.

Values

  1. ReadOnly: file opened for reading only
  2. WriteOnly: file opened for writing only
  3. ReadWrite: file opened for reading and writing
  4. Append: file opened for writing at the end of the file
  5. Truncate: file opened for writing, erases any previous content
  6. Text: file opened in text mode
  7. Unbuffered: file opened in unbuffered mode

Notes

This is a flag enumeration, that means that you can use multiple values using the | operator. Example:

myObject.open("myfile.txt", File.WriteOnly | File.Append | File.Text);
fr/code/data/file.1332418192.txt.gz · Dernière modification : 2021/02/13 11:23 (modification externe)