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
Sylvain Joubert
KWSys
Commits
23d692bf
Commit
23d692bf
authored
19 years ago
by
Bill Hoffman
Browse files
Options
Downloads
Patches
Plain Diff
ENH: optimization of cwd and do not leak library handle
parent
d67989c2
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
+17
-8
17 additions, 8 deletions
SystemTools.cxx
SystemTools.hxx.in
+1
-2
1 addition, 2 deletions
SystemTools.hxx.in
with
18 additions
and
10 deletions
SystemTools.cxx
+
17
−
8
View file @
23d692bf
...
...
@@ -1258,7 +1258,11 @@ kwsys_stl::string SystemTools::ConvertToOutputPath(const char* path)
// remove double slashes not at the start
kwsys_stl
::
string
SystemTools
::
ConvertToWindowsOutputPath
(
const
char
*
path
)
{
kwsys_stl
::
string
ret
=
path
;
kwsys_stl
::
string
ret
;
// make it big enough for all of path and double quotes
ret
.
reserve
(
strlen
(
path
)
+
3
);
// put path into the string
ret
.
insert
(
0
,
path
);
kwsys_stl
::
string
::
size_type
pos
=
0
;
// first convert all of the slashes
while
((
pos
=
ret
.
find
(
'/'
,
pos
))
!=
kwsys_stl
::
string
::
npos
)
...
...
@@ -1289,12 +1293,11 @@ kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path)
}
// now double quote the path if it has spaces in it
// and is not already double quoted
if
(
ret
.
find
(
" "
)
!=
kwsys_stl
::
string
::
npos
if
(
ret
.
find
(
' '
)
!=
kwsys_stl
::
string
::
npos
&&
ret
[
0
]
!=
'\"'
)
{
kwsys_stl
::
string
result
;
result
=
"
\"
"
+
ret
+
"
\"
"
;
ret
=
result
;
ret
.
insert
(
0
,
1
,
'\"'
);
ret
.
append
(
1
,
'\"'
);
}
return
ret
;
}
...
...
@@ -1970,7 +1973,7 @@ int SystemTools::ChangeDirectory(const char *dir)
return
Chdir
(
dir
);
}
kwsys_stl
::
string
SystemTools
::
GetCurrentWorkingDirectory
()
kwsys_stl
::
string
SystemTools
::
GetCurrentWorkingDirectory
(
bool
collapse
)
{
char
buf
[
2048
];
const
char
*
cwd
=
Getcwd
(
buf
,
2048
);
...
...
@@ -1979,8 +1982,11 @@ kwsys_stl::string SystemTools::GetCurrentWorkingDirectory()
{
path
=
cwd
;
}
return
SystemTools
::
CollapseFullPath
(
path
.
c_str
());
if
(
collapse
)
{
return
SystemTools
::
CollapseFullPath
(
path
.
c_str
());
}
return
path
;
}
kwsys_stl
::
string
SystemTools
::
GetProgramPath
(
const
char
*
in_name
)
...
...
@@ -2303,11 +2309,14 @@ int PortableGetLongPathName(const char* pathIn,
int
len
=
(
*
func
)(
shortPath
.
c_str
(),
buffer
,
MAX_PATH
+
1
);
if
(
len
==
0
||
len
>
MAX_PATH
+
1
)
{
FreeLibrary
(
lh
);
return
0
;
}
longPath
=
buffer
;
FreeLibrary
(
lh
);
return
len
;
}
FreeLibrary
(
lh
);
}
return
OldWindowsGetLongPath
(
shortPath
.
c_str
(),
longPath
);
}
...
...
This diff is collapsed.
Click to expand it.
SystemTools.hxx.in
+
1
−
2
View file @
23d692bf
...
...
@@ -580,7 +580,7 @@ public:
/**
* Get current working directory CWD
*/
static kwsys_stl::string GetCurrentWorkingDirectory();
static kwsys_stl::string GetCurrentWorkingDirectory(
bool collapse =true
);
/**
* Change directory the the directory specified
...
...
@@ -668,7 +668,6 @@ private:
* Each time 'dir' will be found it will be replace by 'refdir'
*/
static SystemToolsTranslationMap *TranslationMap;
friend class SystemToolsManager;
};
...
...
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