HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_FileUtils Class Reference

#include <PDG_FileUtils.h>

+ Inheritance diagram for PDG_FileUtils:

Public Types

enum  TransferType { eTransferTempDir, eTransferWorkingDir, eTransferScript, eTransferAsset }
 Enumeration of file transfer destination paths. More...
 
using ViewerPair = std::pair< UT_StringHolder, bool >
 

Public Member Functions

const UT_StringSettags () const
 Returns the set of available tags. More...
 
void tags (const UT_StringHolder &prefix, UT_StringArray &sorted_tags) const
 Returns the sorted list of tags for the given prefix. More...
 
bool isViewable (const UT_StringHolder &tag) const
 Returns true if the tag is viewable. More...
 
const ViewerPairtagToViewer (const UT_StringHolder &tag) const
 Looks up the viewer application for a tag. More...
 
const ViewerPairpathToViewer (const UT_StringHolder &path) const
 Loops up the viewer application for a path. More...
 
const UT_StringHolderpathToTag (const UT_StringHolder &path) const
 Looks up the file tag for a full file path. More...
 
const UT_StringHolderextensionToTag (const char *ext, const UT_StringHolder &def) const
 Looks up the file tag for an extension. More...
 
UT_StringHolder pathToExtension (const UT_StringHolder &path) const
 
void addTag (const UT_StringHolder &tag)
 
void addExtensionTag (const UT_StringHolder &ext, const UT_StringHolder &tag)
 Adds an extension -> tag mapping. More...
 
void addTagViewer (const UT_StringHolder &tag, const UT_StringHolder &viewer, bool is_multiviewer=false)
 Adds a tag -> viewer application mapping. More...
 
bool checkCached (const UT_StringHolder &local_path, const PDG_File &file, PDG_WorkItem *work_item) const
 Checks if a given file path is cached. More...
 
bool statFile (const UT_StringHolder &local_path, const PDG_File &file, const PDG_WorkItem *work_item, PDG_File::Hash &file_hash, exint &file_size) const
 Returns the hash/mod time of the file. More...
 
void dirtyFiles (const PDG_WorkItem *work_item, const PDG_File::Set &files, bool delete_items, bool remove_outputs) const
 
bool transferFile (const PDG_Scheduler *scheduler, const PDG_WorkItem *work_item, const PDG_File &file, TransferType default_type, UT_WorkBuffer &errors) const
 
UT_StringHolder formatTransferPath (const PDG_Scheduler *scheduler, const UT_StringHolder &local_path, TransferType default_type, bool local) const
 

Static Public Member Functions

static int compareFilePaths (const UT_StringHolder &left, const UT_StringHolder &right)
 
static bool makeIntermediateDirs (const char *full_path)
 Makes intermediate directories. More...
 
static UT_StringHolder makeURL (const UT_StringHolder &scheme, const UT_StringHolder &path)
 Formats a URL given a scheme and url body. More...
 
static bool hasDuplicateFiles (const PDG_File::Array &files, PDG_File::Set &duplicates)
 

Static Public Attributes

static const UT_StringHolder theFileTag
 Default tag for any file. More...
 
static const UT_StringHolder theArchiveTag
 Default tag for an archive. More...
 
static const UT_StringHolder theCsvTag
 Default tag for an archive. More...
 
static const UT_StringHolder theGeoTag
 Default tag for geometry. More...
 
static const UT_StringHolder theUSDTag
 Default tag for USD. More...
 
static const UT_StringHolder theImageTag
 Default tag for imgages. More...
 
static const UT_StringHolder theTextTag
 Default tag for text data. More...
 
static const UT_StringHolder theVideoTag
 Default tag for videos. More...
 
static const UT_StringHolder theHipTag
 Default tag for hip files. More...
 
static const UT_StringHolder theHdaTag
 Default tag for hda files. More...
 
static const UT_StringHolder thePythonScriptTag
 Default tag for Python script files. More...
 
static const UT_StringHolder theDirectoryTag
 Default tag for directories. More...
 
static const UT_StringHolder theSymLinkTag
 Default tag for sym links. More...
 
static const ViewerPair theDefaultViewer
 Default viewer application. More...
 

Protected Member Functions

 PDG_FileUtils (const PDG_CustomHandlers *handlers, bool init_defaults)
 
- Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable
 UT_NonCopyable ()=default
 
 ~UT_NonCopyable ()=default
 
 UT_NonCopyable (const UT_NonCopyable &)=delete
 
UT_NonCopyableoperator= (const UT_NonCopyable &)=delete
 

Friends

class PDG_TypeRegistry
 

Detailed Description

Definition at line 33 of file PDG_FileUtils.h.

Member Typedef Documentation

using PDG_FileUtils::ViewerPair = std::pair<UT_StringHolder, bool>

Pair of viewer application, and whether the application supports open multiple files

Definition at line 38 of file PDG_FileUtils.h.

Member Enumeration Documentation

Enumeration of file transfer destination paths.

Enumerator
eTransferTempDir 

The default temp file directory. Most files go here, unless they're one of the special cases below

eTransferWorkingDir 

The file goes into the scheduler's workingDir instead of the temporary file directory

eTransferScript 

The file is a python script and goes to the scheduler's scriptDir, which normally a special path on the temp dir that gets added to the Python path

eTransferAsset 

The file is a digital asset and goes to the tempDir/otls directory, which is added to the OTL search path.

Definition at line 83 of file PDG_FileUtils.h.

Constructor & Destructor Documentation

PDG_FileUtils::PDG_FileUtils ( const PDG_CustomHandlers handlers,
bool  init_defaults 
)
protected

Initializes the file mapping object and optionally loads in the default, built-in tags/extension mappings.

Member Function Documentation

void PDG_FileUtils::addExtensionTag ( const UT_StringHolder ext,
const UT_StringHolder tag 
)

Adds an extension -> tag mapping.

void PDG_FileUtils::addTag ( const UT_StringHolder tag)

Adds a tag to the system, without establishing an extension - >tag mapping. For non-file based tags

void PDG_FileUtils::addTagViewer ( const UT_StringHolder tag,
const UT_StringHolder viewer,
bool  is_multiviewer = false 
)

Adds a tag -> viewer application mapping.

bool PDG_FileUtils::checkCached ( const UT_StringHolder local_path,
const PDG_File file,
PDG_WorkItem work_item 
) const

Checks if a given file path is cached.

static int PDG_FileUtils::compareFilePaths ( const UT_StringHolder left,
const UT_StringHolder right 
)
static

Compares the file paths and returns 0 if they're equal, -1 if the left path is ordered first, and 1 if the right path is ordered first. The paths are first compared directly as strings, and if they're not equal the paths are normalized to remove extra slashes or .. tokens, then compared again.

void PDG_FileUtils::dirtyFiles ( const PDG_WorkItem work_item,
const PDG_File::Set files,
bool  delete_items,
bool  remove_outputs 
) const

Called when a work item should delete files, and runs any custom handlers that match the item

const UT_StringHolder& PDG_FileUtils::extensionToTag ( const char *  ext,
const UT_StringHolder def 
) const

Looks up the file tag for an extension.

UT_StringHolder PDG_FileUtils::formatTransferPath ( const PDG_Scheduler scheduler,
const UT_StringHolder local_path,
TransferType  default_type,
bool  local 
) const

Returns the path that a local file will be transfered to, based on the transfer type and the file extension.

static bool PDG_FileUtils::hasDuplicateFiles ( const PDG_File::Array files,
PDG_File::Set duplicates 
)
static

Returns true if the specified list of files has any duplicates, and returns the set of duplicates.

bool PDG_FileUtils::isViewable ( const UT_StringHolder tag) const

Returns true if the tag is viewable.

static bool PDG_FileUtils::makeIntermediateDirs ( const char *  full_path)
static

Makes intermediate directories.

static UT_StringHolder PDG_FileUtils::makeURL ( const UT_StringHolder scheme,
const UT_StringHolder path 
)
static

Formats a URL given a scheme and url body.

UT_StringHolder PDG_FileUtils::pathToExtension ( const UT_StringHolder path) const

Return the extension of the given path which may include an archive dot suffix like .bgeo.sc

const UT_StringHolder& PDG_FileUtils::pathToTag ( const UT_StringHolder path) const

Looks up the file tag for a full file path.

const ViewerPair& PDG_FileUtils::pathToViewer ( const UT_StringHolder path) const

Loops up the viewer application for a path.

bool PDG_FileUtils::statFile ( const UT_StringHolder local_path,
const PDG_File file,
const PDG_WorkItem work_item,
PDG_File::Hash file_hash,
exint file_size 
) const

Returns the hash/mod time of the file.

const UT_StringSet& PDG_FileUtils::tags ( ) const

Returns the set of available tags.

void PDG_FileUtils::tags ( const UT_StringHolder prefix,
UT_StringArray sorted_tags 
) const

Returns the sorted list of tags for the given prefix.

const ViewerPair& PDG_FileUtils::tagToViewer ( const UT_StringHolder tag) const

Looks up the viewer application for a tag.

bool PDG_FileUtils::transferFile ( const PDG_Scheduler scheduler,
const PDG_WorkItem work_item,
const PDG_File file,
TransferType  default_type,
UT_WorkBuffer errors 
) const

Transfers a file from a local path to a remote path accessible by the specified scheduler. The work item indicates what depends on the file, and may be null if the file transfer was initiated for a global file dependency.

Friends And Related Function Documentation

friend class PDG_TypeRegistry
friend

Definition at line 209 of file PDG_FileUtils.h.

Member Data Documentation

const UT_StringHolder PDG_FileUtils::theArchiveTag
static

Default tag for an archive.

Definition at line 44 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theCsvTag
static

Default tag for an archive.

Definition at line 47 of file PDG_FileUtils.h.

const ViewerPair PDG_FileUtils::theDefaultViewer
static

Default viewer application.

Definition at line 80 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theDirectoryTag
static

Default tag for directories.

Definition at line 74 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theFileTag
static

Default tag for any file.

Definition at line 41 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theGeoTag
static

Default tag for geometry.

Definition at line 50 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theHdaTag
static

Default tag for hda files.

Definition at line 68 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theHipTag
static

Default tag for hip files.

Definition at line 65 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theImageTag
static

Default tag for imgages.

Definition at line 56 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::thePythonScriptTag
static

Default tag for Python script files.

Definition at line 71 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theSymLinkTag
static

Default tag for sym links.

Definition at line 77 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theTextTag
static

Default tag for text data.

Definition at line 59 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theUSDTag
static

Default tag for USD.

Definition at line 53 of file PDG_FileUtils.h.

const UT_StringHolder PDG_FileUtils::theVideoTag
static

Default tag for videos.

Definition at line 62 of file PDG_FileUtils.h.


The documentation for this class was generated from the following file: