Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Frida
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coenen, Joachim
Frida
Commits
508c18bc
Commit
508c18bc
authored
9 years ago
by
Wuttke, Joachim
Committed by
Wuttke, Joachim
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor -> separate function wordexp_multi
parent
4d302725
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pub/trivia/file_ops.cpp
+19
-14
19 additions, 14 deletions
pub/trivia/file_ops.cpp
pub/trivia/file_ops.hpp
+1
-0
1 addition, 0 deletions
pub/trivia/file_ops.hpp
with
20 additions
and
14 deletions
pub/trivia/file_ops.cpp
+
19
−
14
View file @
508c18bc
...
@@ -97,7 +97,7 @@ void triv::fname_divide( const string& fname, string *fdir, string *fshort, stri
...
@@ -97,7 +97,7 @@ void triv::fname_divide( const string& fname, string *fdir, string *fshort, stri
}
}
//!
Bash expansion of file name
.
//!
Returns a unique file name obtained by Posix shell expansion of a given pattern
.
string
triv
::
wordexp_unique
(
const
string
&
s
)
string
triv
::
wordexp_unique
(
const
string
&
s
)
{
{
...
@@ -112,6 +112,23 @@ string triv::wordexp_unique( const string& s )
...
@@ -112,6 +112,23 @@ string triv::wordexp_unique( const string& s )
}
}
//! Returns a list of file names obtained by Posix shell expansion of a given pattern.
vector
<
string
>
triv
::
wordexp_multi
(
const
string
&
s
)
{
wordexp_t
p
;
if
(
wordexp
(
s
.
c_str
(),
&
p
,
0
)
)
throw
"cannot expand "
+
s
;
if
(
p
.
we_wordc
==
0
)
throw
"expansion of "
+
s
+
" is empty"
;
vector
<
string
>
ret
;
for
(
size_t
i
=
0
;
i
<
p
.
we_wordc
;
++
i
)
ret
.
push_back
(
p
.
we_wordv
[
i
]
);
wordfree
(
&
p
);
return
ret
;
}
//! Construct tmp file name that is not currently in use.
//! Construct tmp file name that is not currently in use.
string
triv
::
next_tmp_file
(
const
string
&
path_format
)
string
triv
::
next_tmp_file
(
const
string
&
path_format
)
...
@@ -133,9 +150,6 @@ string triv::next_tmp_file( const string& path_format )
...
@@ -133,9 +150,6 @@ string triv::next_tmp_file( const string& path_format )
vector
<
string
>
triv
::
glob_file_list
(
const
string
&
pattern
,
const
string
&
extension
)
vector
<
string
>
triv
::
glob_file_list
(
const
string
&
pattern
,
const
string
&
extension
)
{
{
vector
<
string
>
ret
;
// add extension to input pattern:
string
extended_pattern
=
""
;
string
extended_pattern
=
""
;
vector
<
string
>
words
;
vector
<
string
>
words
;
split
(
pattern
,
words
);
split
(
pattern
,
words
);
...
@@ -151,16 +165,7 @@ vector<string> triv::glob_file_list( const string& pattern, const string& extens
...
@@ -151,16 +165,7 @@ vector<string> triv::glob_file_list( const string& pattern, const string& extens
break
;
break
;
extended_pattern
+=
" "
;
extended_pattern
+=
" "
;
}
}
return
triv
::
wordexp_multi
(
extended_pattern
);
wordexp_t
p
;
if
(
wordexp
(
extended_pattern
.
c_str
(),
&
p
,
0
)
)
throw
"cannot expand "
+
extended_pattern
;
if
(
p
.
we_wordc
==
0
)
throw
"expansion of "
+
extended_pattern
+
" is empty"
;
for
(
size_t
i
=
0
;
i
<
p
.
we_wordc
;
++
i
)
ret
.
push_back
(
p
.
we_wordv
[
i
]
);
wordfree
(
&
p
);
return
ret
;
}
}
...
...
This diff is collapsed.
Click to expand it.
pub/trivia/file_ops.hpp
+
1
−
0
View file @
508c18bc
...
@@ -18,6 +18,7 @@ namespace triv {
...
@@ -18,6 +18,7 @@ namespace triv {
std
::
vector
<
std
::
string
>
glob_file_list
(
std
::
vector
<
std
::
string
>
glob_file_list
(
const
std
::
string
&
pattern
,
const
std
::
string
&
extension
);
const
std
::
string
&
pattern
,
const
std
::
string
&
extension
);
std
::
string
wordexp_unique
(
const
std
::
string
&
s
);
std
::
string
wordexp_unique
(
const
std
::
string
&
s
);
std
::
vector
<
std
::
string
>
wordexp_multi
(
const
std
::
string
&
s
);
std
::
string
next_tmp_file
(
const
std
::
string
&
path_format
);
std
::
string
next_tmp_file
(
const
std
::
string
&
path_format
);
// File read:
// File read:
...
...
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