Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap
Commits
d75f8050
Commit
d75f8050
authored
5 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Patches
Plain Diff
fixed write into the log-file
parent
fbf797eb
No related branches found
No related tags found
1 merge request
!11
fixed write into the log-file
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/dap_file_utils.h
+9
-1
9 additions, 1 deletion
include/dap_file_utils.h
src/dap_common.c
+19
-2
19 additions, 2 deletions
src/dap_common.c
src/dap_file_utils.c
+27
-3
27 additions, 3 deletions
src/dap_file_utils.c
with
55 additions
and
6 deletions
include/dap_file_utils.h
+
9
−
1
View file @
d75f8050
...
...
@@ -56,10 +56,18 @@
*/
bool
dap_valid_ascii_symbols
(
const
char
*
a_dir_path
);
/**
* Check the file for exists
*
* @a_file_path filename pathname
* @return true, if file exists
*/
bool
dap_file_test
(
const
char
*
a_file_path
)
/**
* Check the directory for exists
*
* @dir_path directory pathname
* @
a_
dir_path directory pathname
* @return true, if the file is a directory
*/
bool
dap_dir_test
(
const
char
*
a_dir_path
);
...
...
This diff is collapsed.
Click to expand it.
src/dap_common.c
+
19
−
2
View file @
d75f8050
...
...
@@ -142,6 +142,7 @@ uint32_t ansi_seq_color_len[ 16 ];
static
char
s_last_error
[
LAST_ERROR_MAX
]
=
{
0
};
static
enum
dap_log_level
dap_log_level
=
L_DEBUG
;
static
FILE
*
s_log_file
=
NULL
;
static
char
*
s_log_file_path
=
NULL
;
static
char
log_tag_fmt_str
[
10
];
#ifdef DAP_LOG_HISTORY
...
...
@@ -307,6 +308,9 @@ int dap_common_init( const char *console_title, const char *a_log_file )
dap_fprintf
(
stderr
,
"Can't open log file %s to append
\n
"
,
a_log_file
);
return
-
1
;
}
if
(
s_log_file_path
)
DAP_DELETE
(
s_log_file_path
);
s_log_file_path
=
dap_strdup
(
a_log_file
);
log_page
=
0
;
log_outindex
=
0
;
...
...
@@ -336,6 +340,11 @@ void dap_common_deinit( )
if
(
s_log_file
)
fclose
(
s_log_file
);
if
(
s_log_file_path
){
DAP_DELETE
(
s_log_file_path
);
s_log_file_path
=
NULL
;
}
if
(
temp_buffer
)
DAP_FREE
(
temp_buffer
);
...
...
@@ -581,8 +590,16 @@ static void *log_thread_proc( void *arg )
fwrite
(
logstr
->
str
,
logstr
->
len
,
1
,
stdout
);
#endif
#endif
if
(
s_log_file
)
fwrite
(
logstr
->
str
,
logstr
->
len
,
1
,
s_log_file
);
if
(
s_log_file
)
{
if
(
!
dap_file_test
(
s_log_file_path
))
{
fclose
(
s_log_file
);
s_log_file
=
fopen
(
s_log_file_path
,
"a"
);
}
if
(
s_log_file
)
{
fwrite
(
logstr
->
str
,
logstr
->
len
,
1
,
s_log_file
);
fflush
(
s_log_file
);
}
}
// fwrite( "1234567890", 5, 1, stdout );
...
...
This diff is collapsed.
Click to expand it.
src/dap_file_utils.c
+
27
−
3
View file @
d75f8050
...
...
@@ -59,6 +59,30 @@ bool dap_valid_ascii_symbols(const char *a_string)
return
true
;
}
/**
* Check the file for exists
*
* @a_file_path filename pathname
* @return true, if file exists
*/
bool
dap_file_test
(
const
char
*
a_file_path
)
{
if
(
!
a_file_path
)
return
false
;
#ifdef _WIN32
int
attr
=
GetFileAttributesA
(
a_dir_path
);
if
(
attr
!=
-
1
&&
(
attr
&
FILE_ATTRIBUTE_NORMAL
))
return
true
;
#else
struct
stat
st
;
if
(
!
stat
(
a_file_path
,
&
st
))
{
if
(
S_ISREG
(
st
.
st_mode
))
return
true
;
}
#endif
return
false
;
}
/**
* Check the directory for exists
*
...
...
@@ -75,9 +99,9 @@ bool dap_dir_test(const char * a_dir_path)
return
true
;
#else
struct
stat
st
;
if
(
!
stat
(
a_dir_path
,
&
st
))
{
if
(
S_ISDIR
(
st
.
st_mode
))
return
true
;
if
(
!
stat
(
a_dir_path
,
&
st
))
{
if
(
S_ISDIR
(
st
.
st_mode
))
return
true
;
}
#endif
return
false
;
...
...
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