File

ILxFile1Service

class ILxFile1Service

Public Functions

LxResult FileSystemPath(LXtObjectID self, const char *name, const char **path)
const char *FileSystemDefaultIO(LXtObjectID self, int isForLoad)
LxResult IsAbsolutePath(LXtObjectID self, const char *path)
LxResult ArePathsEqual(LXtObjectID self, const char *path1, const char *path2)
LxResult ParsePath(LXtObjectID self, const char *filename, char *basename, char *path)
LxResult ComposePath(LXtObjectID self, char *filename, const char *basename, const char *path)
LxResult MakeRelative(LXtObjectID self, char *relname, const char *filename, const char *path)
LxResult MakeUnique(LXtObjectID self, char *filename)
LxResult FindExtension(LXtObjectID self, const char *path, const char **extension)
LxResult SetExtension(LXtObjectID self, char *path, const char *extension)
LxResult MakeDirectory(LXtObjectID self, const char *path)
LxResult TestFileType(LXtObjectID self, const char *filename, int *type)
LxResult TestFileMode(LXtObjectID self, const char *filename, int *mode)
LxResult RenameFile(LXtObjectID self, const char *from, const char *to)
LxResult FileCopy(LXtObjectID self, const char *srcFilePath, const char *dstFilePath, int overwrite)
LxResult FileDelete(LXtObjectID self, const char *filename)
LxResult DirDelete(LXtObjectID self, const char *filename)
LxResult OpenFileWithDefaultApp(LXtObjectID self, const char *filename)
LxResult RevealInFileViewer(LXtObjectID self, const char *filename)
LxResult Execute(LXtObjectID self, const char **argv, int show, int force32)
LxResult FileToURL(LXtObjectID self, const char *filename, char *buf, unsigned len)
LxResult FileFromURL(LXtObjectID self, const char *url, char *buf, unsigned len)
const char *FromLocal(LXtObjectID self, char *neutral, const char *local)
const char *ToLocal(LXtObjectID self, char *local, const char *neutral)
const char *ToLocalAlias(LXtObjectID self, char *local, const char *neutral)
LxResult AllocReference(LXtObjectID self, const char *path, void **ppvObj)

LXe_SKIP

This function takes a neutral format filename as an asset reference and locates its referand local file. This is a well-defined mapping which performs a search of the content path, and the filename returned is guaranteed to exist. LXe_NOTFOUND is returned if there is no such asset file. The type is the file type string that would be passed to a file dialog and indicates the type of file that this should be, or can be null to indicate that no user alternates should be allowed. LXe_OK is returned when the file was found as-is, and LXe_FILE_REMAP is returned on a successful remap. If the type argument is present, the user will be asked to locate missing files, which can result in different return codes. LXe_SKIP is returned if the user chose to skip this file. LXe_ABORT is returned if the user chose to abort the entire load operation. Note that LXe_SKIP is a fail code.

  • LXe_FILE_REMAP

ILxVirtualDevice

class ILxVirtualDevice

Public Functions

LxResult Initialize(LXtObjectID self, const char *path)

  • Initialize passed a path to a real file, sets the device to that file if it’s of the right type for this device. Selects the root of the device for attributes and scanning. Returns NOTFOUND otherwise.

  • Select passed a partial path, sets the object to refer to a sub-file within the device. The sub-path is of the form “aa/bbb/c”.

  • Extract writes the contents of the current file in the virtual device to the given real file system location.

  • Scan performs a scan of the current location, calling the visitor for each file inside the directory.

  • Name in scan mode this returns the raw name of the sub-file. Otherwise it returns the nice, human-reablabe name of the current location.

  • Date returns the date string for the scan file or current location.

  • Size returns the size of the scan file or current location.

LxResult Select(LXtObjectID self, const char *sub)
LxResult Extract(LXtObjectID self, const char *dest)
LxResult Scan(LXtObjectID self, LXtObjectID visitor)
LxResult Type(LXtObjectID self, unsigned *type)
LxResult Name(LXtObjectID self, char *buf, unsigned len)
LxResult Date(LXtObjectID self, char *buf, unsigned len)
LxResult Size(LXtObjectID self, double *bytes)

LXsSYSTEM_PATH_PROGRAM

FileSystemPath() returns the standard file path for a given name, as defined by one of the LXsSYSTEM_PATH_ defines.

  • LXsSYSTEM_PATH_EXENAME

  • LXsSYSTEM_PATH_PROJECT

  • LXsSYSTEM_PATH_TEMP

  • LXsSYSTEM_PATH_LICENSE

  • LXsSYSTEM_PATH_RESOURCE

  • LXsSYSTEM_PATH_MODULE

  • LXsSYSTEM_PATH_PREFS

  • LXsSYSTEM_PATH_HELP

  • LXsSYSTEM_PATH_USER

  • LXsSYSTEM_PATH_CONTENT

  • LXsSYSTEM_PATH_ASSET

  • LXsSYSTEM_PATH_SAMPLE

  • LXsSYSTEM_PATH_CONFIGS

  • LXsSYSTEM_PATH_SCRIPTS

  • LXsSYSTEM_PATH_DOCUMENTS

  • LXsSYSTEM_PATH_KITS

  • LXsSYSTEM_PATH_USER_KITS

  • LXsSYSTEM_PATH_LOGS

  • LXsSYSTEM_PATH_CLOUDCACHE

  • LXsSYSTEM_PATH_USER_CONTENT

ILxFileService

class ILxFileService

Plug-ins can use the File service for various file operations, such as looking up standard file paths by name, or copying files from one location to another. Also see PlatformService for functions to walk the list of all aliased paths and for walking the list of import paths.

Public Functions

LxResult FileSystemPath(LXtObjectID self, const char *name, const char **path)
LxResult IsAbsolutePath(LXtObjectID self, const char *path)

This returns LXe_TRUE if a path is absolute, and LXe_FALSE if it is not.

LxResult ArePathsEqual(LXtObjectID self, const char *path1, const char *path2)

This compares two paths and returns true if they are equal. This respects case-sensitivity and other quirks specific to the operating system. It doesn’t follow symbolic links or other directory traversal.

LxResult ParsePath(LXtObjectID self, const char *filename, unsigned component, char *buf, unsigned len)

This parses a filename path, extracting the last portion of the path into the basename buffer and the path into the path buffer.

LxResult ComposePath(LXtObjectID self, const char *basename, const char *path, char *buf, unsigned len)

This adds the base filename onto a path with the path separator defined by the OS. If the basename is absolute it returns LXe_INVALIDARG.

LxResult SetExtension(LXtObjectID self, const char *filename, const char *extension, char *buf, unsigned len)

This takes a filename and extension, and returns the same filename but with the new extension. The extension string is just the part after the period.

LxResult MakeRelative(LXtObjectID self, const char *filename, const char *path, char *buf, unsigned len)

This makes a filename relative to a path, if possible. This fails if the filename could not be made relative.

LxResult MakeUnique(LXtObjectID self, const char *filename, char *buf, unsigned len)

This computes a unique filename given a base pattern by adding digits. For example, if the path is “c:\a\b\myfile.ext”, this will first see if “c:\a\b\myfile.ext” exists. If it does not, it will be returned. If it does exist, then the path will be changed to “c:\a\b\myfile_1.ext” and tested again, and so on until the path is unique. This method fails if the path portion doesn’t exist.

LxResult MakeDirectory(LXtObjectID self, const char *path)

Given a path to a directory, this creates the directories, if possible.

LxResult TestFileType(LXtObjectID self, const char *filename, unsigned *type)

NONE indicates that the file does not exist or cannot be accessed for some reason. UNKNOWN indicates that the file exists but is some unusual type.

LxResult TestFileMode(LXtObjectID self, const char *filename, unsigned *mode)

This returns a combination of flags indicating if a file can be read and/or written. This method always succeeds, even if the file doesn’t exist.

LxResult RenameFile(LXtObjectID self, const char *from, const char *to)

This renames a file on disk, if possible. This will also work on directories. This can also be used to move files.

LxResult FileCopy(LXtObjectID self, const char *srcFilePath, const char *dstFilePath, unsigned overwrite)

This copies a file from one path to another. If a file already exists at the destination path and overwrite is true, it will be overwritten with no warning given. If overwrite is false, then the method will fail if a file already exists at the destination.

LxResult FileDelete(LXtObjectID self, const char *filename)

This deletes a file from disk, if possible. In general, this must be a file (not a directory).

LxResult DirDelete(LXtObjectID self, const char *filename)

This deletes a dir from disk.

LxResult OpenFileWithDefaultApp(LXtObjectID self, const char *filename)

This opens a file in the application associated with it by the operating system.

LxResult RevealInFileViewer(LXtObjectID self, const char *filename)

This finds the file/folder and selects it in Explorer/Finder. Calling this with a folder will open the parent in Explorer/Finder and select it, while using OpenFileWithDefaultApp() on a folder would show the contents of the folder itself.

LxResult Execute(LXtObjectID self, const char **argv, int show, int force32)

This executes an arbitrary program given an argv-style array of arguments. If “show” is true, the application will be visible when launched; if false, it will be hidden. If force32 is true, the 32 bit version of the application will be launched on a 64 bit system if available supports fat/universal binaries (such as OS X); otherwise, the native version of the application will launch.

LxResult FileToURL(LXtObjectID self, const char *filename, char *buf, unsigned len)

These two utilities convert between local paths and URLs. These paths begin with the “file://” URL prefix.

LxResult FileFromURL(LXtObjectID self, const char *url, char *buf, unsigned len)
LxResult FromLocal(LXtObjectID self, const char *local, char *buf, unsigned len)

Local file and path names can be converted to and from neutral format with these interfaces. The value returned is the result of the conversion. These conversions are raw, performing a simple conversion without validity checks. Aliases are not used in the first two methods, they are in ‘ToLocalAlias’.

LxResult ToLocal(LXtObjectID self, char *neutral, char *buf, unsigned len)
LxResult ToLocalAlias(LXtObjectID self, const char *neutral, char *buf, unsigned len)
LxResult AllocReference(LXtObjectID self, const char *path, void **ppvObj)
LxResult FindSequencePattern(LXtObjectID self, const char *filename, char *buf, unsigned len)
LxResult FindSequenceBounds(LXtObjectID self, const char *pattern, unsigned *first, unsigned *last)
LxResult GenerateSequenceName(LXtObjectID self, const char *pattern, unsigned frame, char *buf, unsigned len)
LxResult ValidateLicense(LXtObjectID self, const char *product, int versionNum)

Takes a product name and version number and returns LXe_OK if there is a valid license.

LxResult FileDateString(LXtObjectID self, const char *filename, char *buf, int len)

It is often useful to know the modification time of a file in a platform-agnostic format. This method returns that as a string of “YYYY:MM:DD HH:MM:SS”. This assures that sorting date strings using strcmp()-like functions puts the dates in chronological order.

LxResult AllocRedirect(LXtObjectID self, void **ppvObj)

Allocate a redirection object from the service. When created it has no history so no redirections are done.

LxResult MakeLegalFilename(LXtObjectID self, char *filename, int replaceDot)

This in-place modifies a C string, replacing characters with special meaning in the OS (like slashes and colons) with underscores. If replacedDot is true, periods will also be replaced. This should only be called on filenmaes, as it will remove the slashes and colons from full paths. This returns LXe_TRUE if the path was already legal, and LXe_FALSE if any characters were replaced with underscores.

LxResult FileSystemPath(const char *name, std::string &path)

User Class Only:


LXiFILECOMP_DIRECTORY

The components of the path are the directory, the base filename with extension, the root name without extension, and the extension itself.

  • LXiFILECOMP_BASENAME

  • LXiFILECOMP_ROOTNAME

  • LXiFILECOMP_EXTENSION


LXiFILETYPE_NONE

This returns LXe_TRUE if a file exists, and LXe_FALSE if it does not. More detailed information can be returned in the type argument (if non-NULL), and will be one of the following defines.

  • LXiFILETYPE_NORMAL

  • LXiFILETYPE_DIRECTORY

  • LXiFILETYPE_UNKNOWN

  • LXiFILETYPE_UNRESOLVED

  • LXiFILEMODE_READ

  • LXiFILEMODE_WRITE

ILxFileReference

class ILxFileReference

Public Functions

LxResult Path(LXtObjectID self, const char **path)
LxResult NiceName(LXtObjectID self, char *buf, unsigned len)
LxResult Type(LXtObjectID self, unsigned *type)
LxResult Mode(LXtObjectID self, unsigned *mode)
LxResult SubCount(LXtObjectID self, unsigned *count)
LxResult SubByIndex(LXtObjectID self, unsigned index, void **ppvObj)

LXsSTAGED_FILE_LIST

The staged file list contains a list of source and destination file paths, that will be copied the next time modo is started up. This copying is done before any plug-ins are loaded.

ILxFileRedirect

class ILxFileRedirect

A file redirection object allows path names from a file to be mapped to an equivalant path found through some method of redirection. This is normally used when loading a file to find all other related assets.

Public Functions

LxResult NeutralFormat(LXtObjectID self, unsigned allow)

Configure the redirection to support neutral format names. This means that references are in a format that is the same on all platforms, so that a file saved on a PC can be loaded on a Mac. If this format is enabled aliases are also supported.

LxResult AddSearchPath(LXtObjectID self, const char *path)

The search path for a redirection object is intended to be set once. Paths will be searched in the order they’re added.

LxResult Locate(LXtObjectID self, const char *path, const char *type, char *buf, unsigned len)

This method takes a reference path and tries to find an absolute path to an existing asset matching the reference. The input reference may be absolute or relative, and must be in neutral format if this object is also. The file type is used to open a redirection dialog by the user, and can be left null to suppress that.

LxResult LocateSequence(LXtObjectID self, const char *pattern, const char *type, unsigned *first, unsigned *last, char *buf, unsigned len)

A sequence filename (one that contains sequence pattern) can be found using the same search criteria.

LxResult Reference(LXtObjectID self, const char *path, char *buf, unsigned len)

This method takes an absolute asset path and returns a reference. The reference may be relative if the asset can be found on the search path. For neutral format redirction the reference is platform-generic and may contain user aliases.