Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
scouting-demonstrator
scdaq
Commits
df7205c4
Commit
df7205c4
authored
9 months ago
by
Giovanna Lazzari Miotto
Browse files
Options
Downloads
Patches
Plain Diff
ref: tools: Move dir creation helper
parent
e5470a81
No related branches found
No related tags found
1 merge request
!109
Introduce pipeline synchronization, output template and parallel sink
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/OutputFileHandler.cc
+1
-24
1 addition, 24 deletions
src/OutputFileHandler.cc
src/OutputFileHandler.h
+0
-2
0 additions, 2 deletions
src/OutputFileHandler.h
src/tools.cc
+22
-0
22 additions, 0 deletions
src/tools.cc
src/tools.h
+2
-0
2 additions, 0 deletions
src/tools.h
with
25 additions
and
26 deletions
src/OutputFileHandler.cc
+
1
−
24
View file @
df7205c4
...
...
@@ -73,34 +73,11 @@ int OutputFileHandler::StageBuffer(char* buffer, size_t size_bytes, uint32_t siz
return
outputFile_
.
Write
(
buffer
,
size_bytes
,
size_orbits
);
}
void
OutputFileHandler
::
create_output_directory_maybe
(
std
::
string
&
output_directory
)
{
struct
stat
sb
;
LOG
(
TRACE
)
<<
"checking if working directory "
<<
output_directory
<<
" exists "
;
/* check if path exists and is a directory */
if
(
stat
(
output_directory
.
c_str
(),
&
sb
)
==
0
)
{
if
(
S_ISDIR
(
sb
.
st_mode
))
{
// output directory already exists
return
;
}
std
::
string
err
=
"ERROR The output directory path '"
+
output_directory
+
"' exists, but the path is not a directory!"
;
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
if
(
!
tools
::
filesystem
::
create_directories
(
output_directory
))
{
std
::
string
err
=
tools
::
strerror
(
"ERROR when creating the output directory '"
+
output_directory
+
"'"
);
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
LOG
(
TRACE
)
<<
"Created output directory: "
<<
output_directory
<<
"'."
;
}
void
OutputFileHandler
::
open_new_file
()
{
// Create a new file
uint32_t
ls
=
1
+
static_cast
<
uint32_t
>
(
current_index_
/
(
ls_
.
max_index
+
1
));
auto
working_dir
=
loc_
.
GetWorkingDir
(
run_
.
number
);
create_output_d
irectory
_maybe
(
working_dir
);
tools
::
CreateD
irectory
(
working_dir
);
LOG
(
TRACE
)
<<
"opening file with index "
<<
current_index_
<<
", in lumisection "
<<
ls
;
outputFile_
=
...
...
This diff is collapsed.
Click to expand it.
src/OutputFileHandler.h
+
0
−
2
View file @
df7205c4
...
...
@@ -98,8 +98,6 @@ class OutputFileHandler {
void
CommitEnqueued
();
private
:
void
create_output_directory_maybe
(
std
::
string
&
output_directory
);
void
open_new_file
();
std
::
string
FormatFilename
(
uint32_t
run_number
,
uint32_t
index
,
uint32_t
ls
);
...
...
This diff is collapsed.
Click to expand it.
src/tools.cc
+
22
−
0
View file @
df7205c4
...
...
@@ -24,6 +24,28 @@ std::string FormatFileIndex(uint32_t index) {
return
ss
.
str
();
}
void
CreateDirectory
(
std
::
string
&
dir_path
)
{
struct
stat
sb
;
LOG
(
TRACE
)
<<
"checking if working directory "
<<
dir_path
<<
" exists "
;
/* check if path exists and is a directory */
if
(
stat
(
dir_path
.
c_str
(),
&
sb
)
==
0
)
{
if
(
S_ISDIR
(
sb
.
st_mode
))
{
// output directory already exists
return
;
}
std
::
string
err
=
"ERROR The output directory path '"
+
dir_path
+
"' exists, but the path is not a directory!"
;
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
if
(
!
filesystem
::
create_directories
(
dir_path
))
{
std
::
string
err
=
strerror
(
"ERROR when creating the output directory '"
+
dir_path
+
"'"
);
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
LOG
(
TRACE
)
<<
"Created output directory: "
<<
dir_path
<<
"'."
;
}
namespace
log
{
/* Definitions of forward declarations from log.h */
...
...
This diff is collapsed.
Click to expand it.
src/tools.h
+
2
−
0
View file @
df7205c4
...
...
@@ -22,6 +22,8 @@ std::string FormatRun(uint32_t run_number);
std
::
string
FormatLumisection
(
uint32_t
ls
);
std
::
string
FormatFileIndex
(
uint32_t
index
);
void
CreateDirectory
(
std
::
string
&
dir_path
);
/*
* A thread-safe version of strerror: Returns a C++ std::string describing
* error_code
...
...
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