All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
filesystem object

Path: /sdk/add_on/scriptfile/

This object provides support for inspecting directories on the filesystem.

Register with `RegisterScriptFileSystem(asIScriptEngine*)`.

# Public C++ interface

class CScriptFileSystem
{
public:
CScriptFileSystem();
void AddRef() const;
void Release() const;
// Sets the current path that should be used in other calls when using relative paths
// It can use relative paths too, so moving up a directory is used by passing in ".."
bool ChangeCurrentPath(const std::string &path);
std::string GetCurrentPath() const;
// Returns true if the path is a directory. Input can be either a full path or a relative path.
// This method does not return the dirs '.' and '..'
bool IsDir(const std::string &path) const;
// Returns true if the path is a link. Input can be either a full path or a relative path
bool IsLink(const std::string &path) const;
// Returns the size of file. Input can be either a full path or a relative path
asINT64 GetSize(const std::string &path) const;
// Returns a list of the files in the current path
CScriptArray *GetFiles() const;
// Returns a list of the directories in the current path
CScriptArray *GetDirs() const;
// Creates a new directory. Returns 0 on success
int MakeDir(const std::string &path);
// Removes a directory. Will only remove the directory if it is empty. Returns 0 on success
int RemoveDir(const std::string &path);
// Deletes a file. Returns 0 on success
int DeleteFile(const std::string &path);
// Copies a file. Returns 0 on success
int CopyFile(const std::string &source, const std::string &target);
// Moves or renames a file or directory. Returns 0 on success
int Move(const std::string &source, const std::string &target);
};

# Public script interface

      class filesystem
      {
        bool           changeCurrentPath(const string &in);
        string         getCurrentPath() const;
        array<string> @getDirs();
        array<string> @getFiles();
        bool           isDir(const string &in);
        bool           isLink(const string &in) const;
        int64          getSize(const string &in) const;
        int            makeDir(const string &in);
        int            removeDir(const string &in);
        int            deleteFile(const string &in);
        int            copyFile(const string &in, const string &in);
        int            move(const string &in, const string &in);
      }

bool changeCurrentPath(const string &in path)

This changes the current directory used by the filesystem object. It will return true if the given path is valid.

It doesn't change the application' working directory.

string getCurrentPath() const

Returns the current path used by the filesystem object.

array<string> @getDirs()

Returns a list with the names of all directories in the current path.

array<string> @getFiles()

Returns a list with the names of all files in the current path.

bool isDir(const string &in path)

Returns true if the given path is a directory.

bool isLink(const string &in path)

Returns true if the given path is a link.

int64 getSize(const string &in) const

Returns the size of a file.

int makeDir(const string &in)

Creates a new directory. Returns 0 on success.

int removeDir(const string &in)

Removes a directory. Will only remove the directory if it is empty. Returns 0 on success.

int deleteFile(const string &in)

Deletes a file. Returns 0 on success.

int copyFile(const string &in, const string &in)

Copies a file. Returns 0 on success.

int move(const string &in, const string &in)

Moves or renames a file or directory. Returns 0 on success.