Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
openocd
Commits
a78762e7
Commit
a78762e7
authored
Jun 27, 2008
by
oharboe
Browse files
export find_file function
git-svn-id:
svn://svn.berlios.de/openocd/trunk@732
b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent
a61fe67b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/helper/configuration.c
View file @
a78762e7
...
...
@@ -54,17 +54,13 @@ void add_config_file_name (const char *cfg)
config_file_names
[
num_config_files
]
=
NULL
;
}
FILE
*
open_file_from_path
(
char
*
file
,
char
*
mode
)
/* return full path or NULL according to search rules */
char
*
find_file
(
char
*
file
)
{
if
(
mode
[
0
]
!=
'r'
)
{
return
fopen
(
file
,
mode
);
}
else
{
FILE
*
fp
=
NULL
;
char
**
search_dirs
=
script_search_dirs
;
char
*
dir
;
char
const
*
mode
=
"r"
;
char
full_path
[
1024
];
/* Check absolute and relative to current working dir first.
...
...
@@ -82,11 +78,29 @@ FILE *open_file_from_path (char *file, char *mode)
snprintf
(
full_path
,
1024
,
"%s/%s"
,
dir
,
file
);
fp
=
fopen
(
full_path
,
mode
);
}
if
(
fp
)
LOG_DEBUG
(
"opened %s"
,
full_path
);
{
fclose
(
fp
);
LOG_DEBUG
(
"found %s"
,
full_path
);
return
strdup
(
full_path
);
}
return
NULL
;
}
return
fp
;
FILE
*
open_file_from_path
(
char
*
file
,
char
*
mode
)
{
if
(
mode
[
0
]
!=
'r'
)
{
return
fopen
(
file
,
mode
);
}
else
{
char
*
full_path
=
find_file
(
file
);
FILE
*
fp
=
NULL
;
fp
=
fopen
(
full_path
,
mode
);
free
(
full_path
);
return
fp
;
}
}
...
...
src/helper/configuration.h
View file @
a78762e7
...
...
@@ -29,5 +29,6 @@ extern void add_config_file_name (const char *cfg);
extern
void
add_script_search_dir
(
const
char
*
dir
);
extern
int
configuration_output_handler
(
struct
command_context_s
*
context
,
char
*
line
);
extern
FILE
*
open_file_from_path
(
char
*
file
,
char
*
mode
);
extern
char
*
find_file
(
char
*
name
);
#endif
/* CONFIGURATION_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment