Package Internal.FileSystem is an internal package that contains low level functions as interface to the file system. These functions should not be called directly in a scripting environment since more convenient functions are provided in packages Files and Systems.
Note, the functions in this package are direct interfaces to functions of POSIX and of the standard C library. Errors occuring in these functions are treated by triggering a Modelica assert. Therefore, the functions in this package return only for a successful operation. Furthermore, the representation of a string is hidden by this interface, especially if the operating system supports Unicode characters.
Extends from Modelica.Icons.Package (Icon for standard packages).
| Name | Description |
|---|---|
| Make directory (POSIX: 'mkdir') | |
| Remove empty directory (POSIX function 'rmdir') | |
| Inquire file information (POSIX function 'stat') | |
| Rename existing file or directory (C function 'rename') | |
| Remove existing file (C function 'remove') | |
| Copy existing file (C functions 'fopen', 'getc', 'putc', 'fclose') | |
| Read names of a directory (POSIX functions opendir, readdir, closedir) | |
| Get number of files and directories in a directory (POSIX functions opendir, readdir, closedir) |
Modelica.Utilities.Internal.FileSystem.mkdir
| Type | Name | Default | Description |
|---|---|---|---|
| String | directoryName | Make a new directory |
function mkdir "Make directory (POSIX: 'mkdir')" extends Modelica.Icons.Function; input String directoryName "Make a new directory"; external "C" ModelicaInternal_mkdir(directoryName);end mkdir;
Modelica.Utilities.Internal.FileSystem.rmdir
| Type | Name | Default | Description |
|---|---|---|---|
| String | directoryName | Empty directory to be removed |
function rmdir "Remove empty directory (POSIX function 'rmdir')" extends Modelica.Icons.Function; input String directoryName "Empty directory to be removed"; external "C" ModelicaInternal_rmdir(directoryName);end rmdir;
Modelica.Utilities.Internal.FileSystem.stat
| Type | Name | Default | Description |
|---|---|---|---|
| String | name | Name of file, directory, pipe etc. |
| Type | Name | Description |
|---|---|---|
| FileType | fileType | Type of file |
function stat "Inquire file information (POSIX function 'stat')" extends Modelica.Icons.Function; input String name "Name of file, directory, pipe etc."; output Types.FileType fileType "Type of file"; external "C" fileType = ModelicaInternal_stat(name);end stat;
Modelica.Utilities.Internal.FileSystem.rename
| Type | Name | Default | Description |
|---|---|---|---|
| String | oldName | Current name | |
| String | newName | New name |
function rename "Rename existing file or directory (C function 'rename')" extends Modelica.Icons.Function; input String oldName "Current name"; input String newName "New name"; external "C" ModelicaInternal_rename(oldName, newName);end rename;
Modelica.Utilities.Internal.FileSystem.removeFile
| Type | Name | Default | Description |
|---|---|---|---|
| String | fileName | File to be removed |
function removeFile "Remove existing file (C function 'remove')" extends Modelica.Icons.Function; input String fileName "File to be removed"; external "C" ModelicaInternal_removeFile(fileName);end removeFile;
Modelica.Utilities.Internal.FileSystem.copyFile
| Type | Name | Default | Description |
|---|---|---|---|
| String | fromName | Name of file to be copied | |
| String | toName | Name of copy of file |
function copyFile "Copy existing file (C functions 'fopen', 'getc', 'putc', 'fclose')" extends Modelica.Icons.Function; input String fromName "Name of file to be copied"; input String toName "Name of copy of file"; external "C" ModelicaInternal_copyFile(fromName, toName);end copyFile;
Modelica.Utilities.Internal.FileSystem.readDirectory
| Type | Name | Default | Description |
|---|---|---|---|
| String | directory | Name of the directory from which information is desired | |
| Integer | nNames | Number of names that are returned (inquire with getNumberOfFiles) |
| Type | Name | Description |
|---|---|---|
| String | names[nNames] | All file and directory names in any order from the desired directory |
function readDirectory
"Read names of a directory (POSIX functions opendir, readdir, closedir)"
extends Modelica.Icons.Function;
input String directory
"Name of the directory from which information is desired";
input Integer nNames
"Number of names that are returned (inquire with getNumberOfFiles)";
output String names[nNames]
"All file and directory names in any order from the desired directory";
external "C" ModelicaInternal_readDirectory(directory,nNames,names);
end readDirectory;
Modelica.Utilities.Internal.FileSystem.getNumberOfFiles
| Type | Name | Default | Description |
|---|---|---|---|
| String | directory | Directory name |
| Type | Name | Description |
|---|---|---|
| Integer | result | Number of files and directories present in 'directory' |
function getNumberOfFiles
"Get number of files and directories in a directory (POSIX functions opendir, readdir, closedir)"
extends Modelica.Icons.Function;
input String directory "Directory name";
output Integer result
"Number of files and directories present in 'directory'";
external "C" result = ModelicaInternal_getNumberOfFiles(directory);
end getNumberOfFiles;