42 #define HOME_SIGNATURE "home:"
43 #define HOME_SIGNATURE_LEN 5
56 using namespace HDK_Sample;
94 #define FS_HOMEREADER_HANDLE_OPTIONS
96 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
98 fsFindLastOption(
const char *option_name,
const UT_WorkArgs &options,
99 UT_String *option_value = NULL,
int *option_index = NULL)
103 option_tag = option_name;
107 option_value->
clear();
110 for(
int i = options.
getArgc()-1; i >= 0; i-- )
128 fsGetFileAndOptions(
const char *
source,
135 source_str.tokenize( list,
'?' );
138 file_str.
harden( count > 0 ? list(0) :
"" );
139 options_str.
harden( count > 1 ? list(1) :
"" );
146 bool do_questionmark =
true;
147 bool do_ampersand =
false;
148 for(
int i = 0; i < options.
getArgc(); i++ )
150 if( i == skip_index )
153 if( do_questionmark )
156 do_questionmark =
false;
162 buff.
append( options(i) );
168 fsSplitPathIntoFileAndSection(
const char *source,
173 int section_option_index;
179 fsGetFileAndOptions( source, file_str, options_str );
180 options_str.
tokenize( options,
'&' );
181 fsFindLastOption(
"section", options, §ion_name, §ion_option_index);
188 fsAppendOptionsExceptForSkipped( buff, options, section_option_index );
195 fsCombineFileAndSectionIntoPath(
UT_String &source,
196 const char *file_name,
const char *section_name)
204 separator = file_name_str.findChar(
'?') ?
'&' :
'?';
207 buffer.
strcpy( file_name );
208 buffer.
append( separator );
209 buffer.
append(
"section=" );
210 buffer.
append( section_name );
227 while( fsSplitPathIntoFileAndSection( path, path, section_name ))
228 sections.
insert( section_name, 0 );
240 for(
int i = 0; i < sections.
entries(); i++ )
247 const UT_WorkArgs &options,
const char *option_name,
248 const char *separator )
252 if( fsFindLastOption( option_name, options, &option_value ))
260 fsProcessNonSectionOptions(
UT_String &source )
272 fsGetFileAndOptions( source, source, options_str );
273 options_str.
tokenize( options,
'&' );
274 UT_ASSERT( ! fsFindLastOption(
"section", options ));
275 fsAppendFileSuffix( source, options,
"version",
"-" );
276 fsAppendFileSuffix( source, options,
"ext",
"." );
279 #endif // FS_HOMEREADER_HANDLE_OPTIONS
298 fsConvertToStandardPathForWrite(
UT_String &destpath,
const char *srcpath)
305 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
315 fsStripSectionOptions( destpath, sections );
316 fsProcessNonSectionOptions( destpath );
317 fsAppendSectionNames( destpath, sections );
320 fsPrefixPathWithHome(destpath);
325 fsConvertToStandardPathForRead(
UT_String &destpath,
const char *srcpath)
332 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
339 fsProcessNonSectionOptions( destpath );
342 fsPrefixPathWithHome(destpath);
347 fsConvertToStandardPathForInfo(
UT_String &destpath,
const char *srcpath)
349 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
356 return fsConvertToStandardPathForRead(destpath, srcpath);
375 if( fsConvertToStandardPathForRead(homepath, source) )
386 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
388 if( !source_section_path ||
406 fsSplitPathIntoFileAndSection( source_section_path,
407 index_file_path, section_name );
417 #endif // FS_HOMEREADER_HANDLE_OPTIONS
422 const char *index_file_path,
423 const char *section_name)
425 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
431 fsCombineFileAndSectionIntoPath( source_section_path,
432 index_file_path, section_name );
441 #endif // FS_HOMEREADER_HANDLE_OPTIONS
461 if( fsConvertToStandardPathForWrite(homepath, source) )
476 const char *source, mode_t
mode,
bool ignore_umask)
479 if (!fsConvertToStandardPathForWrite(homepath, source))
506 if( fsConvertToStandardPathForInfo(homepath, source) )
521 if( fsConvertToStandardPathForInfo(homepath, source) )
536 if( fsConvertToStandardPathForInfo(homepath, source) )
551 if( fsConvertToStandardPathForInfo(homepath, source) )
566 if( fsConvertToStandardPathForInfo(homepath, source) )
568 #ifdef FS_HOMEREADER_HANDLE_OPTIONS
574 fsGetFileAndOptions( source, filename_str, options_str );
575 options_str.
tokenize( options,
'&' );
576 if( fsFindLastOption(
"ext", options, &option_value ))
579 extension += option_value;
596 if( fsConvertToStandardPathForInfo(homepath, source) )
bool canHandle(const char *source) override
Determine whether this helper can process the filename.
bool makeDirectory(const char *source, mode_t mode=0777, bool ignore_umask=false) override
Make a directory and all the parent directories needed.
UT_String getExtension(const char *source) override
static const char * getString(UT_StrControl i)
bool hasAccess(int mode=0) const
~FS_HomeInfoHelper() override
bool splitIndexFileSectionPath(const char *source_section_path, UT_String &index_file_path, UT_String §ion_name) override
bool getIsDirectory(const char *source) override
Return whether the filename is a directory.
bool getIsDirectory() const
Returns if the path is a directory.
GLsizei const GLchar *const * path
FS_ReaderStream * createStream(const char *source, const UT_Options *options) override
If the filename starts with "home:", open an FS_ReaderStream.
SYS_FORCE_INLINE void strcpy(const char *src)
void copyIntoString(UT_String &str) const
int64 getFileDataSize() const
Returns the file size.
void clear()
Reset the string to the default constructor.
unsigned length() const
Return length of string.
const char * buffer() const
bool combineIndexFileSectionPath(UT_String &source_section_path, const char *index_file_path, const char *section_name) override
Class to open a file as a write stream. The class tests for a "home:" prefix and replaces it with $HO...
time_t getModTime(const char *source) override
Get the modification timestamp (returns time_t)
bool getContents(UT_StringArray &contents, UT_StringArray *dirs=0, UT_Array< FS_Stat > *stats=0, UT_Array< FS_Stat > *dir_stats=0)
int tokenize(char *argv[], int max_args, char separator)
bool canMakeDirectory(const char *source) override
Whether this helper supports the given source path for makeDirectory().
~FS_HomeWriteHelper() override
~FS_HomeReadHelper() override
GLsizei GLsizei GLchar * source
void harden()
Take shallow copy and make it deep.
Class to stat a file. The class tests for a "home:" prefix and replaces it with $HOME.
int64 getSize(const char *source) override
Get the file size in bytes.
exint entries() const
Alias of size(). size() is preferred.
UT_API void UTaddAbsolutePathPrefix(const char *prefix)
bool hasAccess(const char *source, int mode) override
time_t getModTime() const
A map of string to various well defined value types.
int substr(UT_String &buf, int index, int len=0) const
virtual UT_String getExtension(const char *source)
SYS_FORCE_INLINE bool UTisstring(const char *s)
SYS_FORCE_INLINE void append(char character)
#define HOME_SIGNATURE_LEN
Class to open a file as a read stream. The class tests for a "home:" prefix and replaces it with $HOM...
FS_WriterStream * createStream(const char *source) override
If the filename begins with "home:" return a new write stream.
bool startsWith(const UT_StringView &prefix, bool case_sensitive=true) const
Class for retrieving file information.
exint insert(exint index)
static bool makeDirs(const char *path, mode_t mode=0777, bool ignore_umask=false)
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
bool getContents(const char *source, UT_StringArray &contents, UT_StringArray *dirs) override
static void combineStandardIndexFileSectionPath(UT_String &source_section_path, const char *index_file_path, const char *section_name)