Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rolf Eike Beer
KWSys
Commits
17af95bb
Commit
17af95bb
authored
21 years ago
by
Kent Williams
Browse files
Options
Downloads
Patches
Plain Diff
Removed platform-specific functions from Code/IO/itkIOCommon, fixed code to use kwsys/SystemTools
parent
097023a9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SystemTools.cxx
+62
-0
62 additions, 0 deletions
SystemTools.cxx
SystemTools.hxx.in
+11
-0
11 additions, 0 deletions
SystemTools.hxx.in
with
73 additions
and
0 deletions
SystemTools.cxx
+
62
−
0
View file @
17af95bb
...
...
@@ -1016,6 +1016,29 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
return
true
;
}
// return size of file; also returns zero if no file exists
unsigned
long
SystemTools
::
FileLength
(
const
char
*
filename
)
{
struct
stat
fs
;
if
(
stat
(
filename
,
&
fs
)
!=
0
)
{
return
0
;
}
else
{
return
fs
.
st_size
;
}
}
int
SystemTools
::
Strucmp
(
const
char
*
s1
,
const
char
*
s2
)
{
#ifdef _WIN32
return
_stricmp
(
s1
,
s2
);
#else
return
strcasecmp
(
s1
,
s2
);
#endif
}
// return true if the file exists
long
int
SystemTools
::
ModifiedTime
(
const
char
*
filename
)
{
...
...
@@ -1042,6 +1065,45 @@ bool SystemTools::RemoveFile(const char* source)
return
unlink
(
source
)
!=
0
?
false
:
true
;
}
char
*
SystemTools
::
RealPath
(
const
char
*
path
,
char
*
resolved_path
)
{
#if defined(_WIN32)
char
pathpart
[
itk
::
IOCommon
::
ITK_MAXPATHLEN
];
strcpy
(
pathpart
,
path
);
char
fnamepart
[
itk
::
IOCommon
::
ITK_MAXPATHLEN
];
char
*
slash
;
if
((
slash
=
strrchr
(
pathpart
,
'/'
))
==
NULL
)
{
slash
=
strrchr
(
pathpart
,
'\\'
);
}
if
(
slash
==
NULL
)
// no path part, so just use current dir.
{
Getcwd
(
pathpart
,
sizeof
(
pathpart
));
strcpy
(
fnamepart
,
path
);
}
else
// change directory to path part, getcwd to find OS resolved path
{
*
slash
=
'\0'
;
strcpy
(
fnamepart
,
slash
+
1
);
char
savedir
[
itk
::
IOCommon
::
ITK_MAXPATHLEN
];
Getcwd
(
savedir
,
sizeof
(
savedir
));
Chdir
(
pathpart
);
Getcwd
(
pathpart
,
sizeof
(
pathpart
));
Chdir
(
savedir
);
}
strcpy
(
resolved_path
,
pathpart
);
strcat
(
resolved_path
,
"/"
);
strcat
(
resolved_path
,
fnamepart
);
return
resolved_path
;
#else
return
realpath
(
path
,
resolved_path
);
#endif
}
/**
* Find the file the given name. Searches the given path and then
* the system search path. Returns the full path to the file if it is
...
...
This diff is collapsed.
Click to expand it.
SystemTools.hxx.in
+
11
−
0
View file @
17af95bb
...
...
@@ -100,6 +100,11 @@ public:
*/
static kwsys_std::string UpperCase(const kwsys_std::string&);
/**
* do a case-independent string comparison
*/
static int Strucmp(const char *s1, const char *s2);
/**
* Replace Windows file system slashes with Unix-style slashes.
*/
...
...
@@ -123,6 +128,12 @@ public:
/** Return true if a file exists in the current directory. */
static bool FileExists(const char* filename);
static unsigned long FileLength(const char *filename);
/**
* given a (possibly) relative path, return the completely
* qualified path to a file system entity
*/
static char *RealPath(const char *path, char *resolved_path);
/**
* Add the paths from the environment variable PATH to the
* string vector passed in.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment