Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SbFileHelper.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#if !defined SBFILEHELPER_H
24#define SBFILEHELPER_H
25
26#ifndef _WIN32
27#include <unistd.h>
28#endif // _WIN32
29
30#include <sys/types.h>
31#include <sys/stat.h>
32
33#ifdef _WIN32
34#include <io.h>
35#define F_OK 0
36#define W_OK 2
37#define R_OK 4
38#define X_OK 0
39#endif
40
41#include <Inventor/SbString.h>
42
60{
61 // ----------------------- Public usage --------------------------------------
62public:
63#ifdef WIN32
64 typedef struct __stat64 Stat;
65#else
66 typedef struct stat64 Stat;
67#endif
68
77 static FILE* open( const SbString& filename, const char* flags );
78
84 static void close( FILE* fp );
85
89 static
90#if defined(_WIN32)
91 unsigned __int64
92#else
93 unsigned long long
94#endif
95 getFileSize( const SbString& filename );
96
101 {
103 EXISTENCE = F_OK,
105 WRITE = W_OK,
107 READ = R_OK,
109 READ_WRITE = W_OK + R_OK,
111 EXECUTE = X_OK
112 };
113
126 static SbBool isAccessible( const SbString& filename, FileAccess mode=READ );
127
134 static SbString getExtension( const SbString& filename );
135
139 static SbBool isUrl( const SbString& filename );
140
144 static SbBool isFileSystemUrl( const SbString& filename );
145
155 static SbString makeFileSystemURL( const SbString& filename );
156
165
173 static SbString getBaseName( const SbString& fullFilePath );
174
182 static SbString getDirName( const SbString& fullFilePath );
183
191 static SbString toUnixPath( const SbString& path );
192
199 static SbString toWindowsPath( const SbString& path );
200
207
215 static SbString getTempFilename( const SbString& path, const SbString& prefix );
216
223 static int createDirectory( const SbString& directory );
224
229
235 static int setCurrentDirectory( const SbString& directory );
236
240 static bool containsWindowsDrive( const SbString& path );
241
248 static int removeFile( const SbString& fileName );
249
262 static bool getStat(const SbString& filename, SbFileHelper::Stat& stat);
263
267 static SbString cleanUpPath( const SbString& path );
268
274 static SbString expandString( const SbString& string );
275
300 static void listFiles(const SbString& path, const SbString& pattern, std::vector<SbString>& files);
301
302private:
303
312 static int findExtensionPos( const SbString & filename );
313
318 static void setFileExtension( SbString & _filename, const SbString &_strExt );
319
323 static SbString cleanupBadNetworkName( const SbString& string );
324
330 static SbString getOivLocalAppDataPath();
331
335 static SbString getOivLibrariesPath();
336
340 static bool createSubDirectories(const SbString& path);
341
345 static SbBool deleteFile(const SbString& file);
346
347 // ----------------------- Protected usage --------------------------------------
348
349private:
350
351 // ----------------------- Private usage --------------------------------------
352
353private:
354
355};
356
357// ----------------------- Inline functions --------------------------------------
358
359//------------------------------------------------------------------------------
360
361#endif // SBFILEHELPER_H
362
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Utilities class ...
static void close(FILE *fp)
Close a file opened using the open function.
static SbString getExtension(const SbString &filename)
Returns the extension part of the specified filename.
static SbString getDirName(const SbString &fullFilePath)
Returns the directory path part of a full path string.
static int removeFile(const SbString &fileName)
Removes the specified file.
static SbString getTempFilename(const SbString &path, const SbString &prefix)
Returns a temporary filename.
static SbBool isUrl(const SbString &filename)
Returns TRUE if the filename is a network url like: http:// or ftp://.
static FILE * open(const SbString &filename, const char *flags)
Open a file and return a handle to it.
static int setCurrentDirectory(const SbString &directory)
Sets the current working directory.
static bool getStat(const SbString &filename, SbFileHelper::Stat &stat)
This function fills the stat structure with information about the specified file.
static int createDirectory(const SbString &directory)
Create the specified directory.
FileAccess
File access mode enum.
@ READ
Check file for Read access only.
@ WRITE
Check file for Write access only.
@ EXECUTE
Check file for Execution access.
@ EXISTENCE
Check file for existence only.
@ READ_WRITE
Check file for Read and Write access.
struct stat64 Stat
static SbString toWindowsPath(const SbString &path)
Converts a Unix path (with '/') to a Microsoft Windows path (with '\').
static void listFiles(const SbString &path, const SbString &pattern, std::vector< SbString > &files)
Returns a list of the files in directory 'path' that match a 'pattern' Pattern may include the basic ...
static SbString getBaseName(const SbString &fullFilePath)
Returns the filename part of a full path string.
static SbBool isFileSystemUrl(const SbString &filename)
Returns TRUE if the filename is a file system URL like: file://...
static SbString expandString(const SbString &string)
Returns a new version of the string with "$NAME" SoPreference variable names expanded to their define...
static SbString makeFileSystemURL(const SbString &filename)
Converts a filename to a file system URL.
static SbString cleanUpPath(const SbString &path)
Removes all multiple occurences of '/' in the path.
static SbString getCurrentDirectory()
Returns the current directory.
static SbBool isAccessible(const SbString &filename, FileAccess mode=READ)
Returns TRUE if a file is accessible
static SbString getTempDirectory()
Returns the path to the temporary directory used by the system.
static SbString fileSystemURLToFilename(const SbString &url)
Converts a file system URL to a regular filename E.g "file:///c:/temp/test.dat" becomes "c:/temp/te...
static SbString toUnixPath(const SbString &path)
Converts a Microsoft Windows path (with '\') to a Unix path (with '/').
static bool containsWindowsDrive(const SbString &path)
Returns true if the specified path starts with a Microsoft Windows drive letter.
static unsigned long long getFileSize(const SbString &filename)
Returns the size of the specified file in bytes.
Class for smart character strings.
Definition SbString.h:202
int SbBool
Boolean type.
Definition SbBase.h:87