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
412970a9
Commit
412970a9
authored
5 years ago
by
dmitriy.gerasimov
Browse files
Options
Downloads
Plain Diff
Merge branch 'features-2954' into 'master'
Features 2954 See merge request
!33
parents
50bbcf37
81a58386
No related branches found
No related tags found
1 merge request
!33
Features 2954
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/dap_file_utils.h
+12
-0
12 additions, 0 deletions
include/dap_file_utils.h
src/dap_file_utils.c
+31
-0
31 additions, 0 deletions
src/dap_file_utils.c
with
43 additions
and
0 deletions
include/dap_file_utils.h
+
12
−
0
View file @
412970a9
...
...
@@ -22,12 +22,16 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<stdbool.h>
#include
"dap_list.h"
#include
<dirent.h>
#ifndef _DAP_FILE_UTILS_H_
#define _DAP_FILE_UTILS_H_
#ifdef _WIN32
#include
<Windows.h>
/* On Win32, the canonical directory separator is the backslash, and
* the search path separator is the semicolon. Note that also the
* (forward) slash works as directory separator.
...
...
@@ -85,4 +89,12 @@ char* dap_path_get_basename(const char *a_file_name);
bool
dap_path_is_absolute
(
const
char
*
a_file_name
);
char
*
dap_path_get_dirname
(
const
char
*
a_file_name
);
/**
* Get list of subdirectories
*
* @a_path_name directory path.
* @return dap_list_t type variable that contains a list of subdirectories.
*/
dap_list_t
*
dap_get_subs
(
const
char
*
a_path_name
);
#endif // _FILE_UTILS_H_
This diff is collapsed.
Click to expand it.
src/dap_file_utils.c
+
31
−
0
View file @
412970a9
...
...
@@ -368,3 +368,34 @@ char* dap_path_get_dirname(const char *a_file_name)
return
l_base
;
}
dap_list_t
*
dap_get_subs
(
const
char
*
a_path_dir
){
dap_list_t
*
list
=
dap_list_alloc
();
#ifdef _WIN32
size_t
m_size
=
strlen
(
a_path_dir
);
char
*
m_path
=
DAP_NEW_SIZE
(
char
,
m_size
+
2
);
memcpy
(
m_path
,
a_path_dir
,
m_size
);
m_path
[
m_size
]
=
'*'
;
m_path
[
m_size
+
1
]
=
'\0'
;
WIN32_FIND_DATA
info_file
;
HANDLE
h_find_file
=
FindFirstFileA
(
m_path
,
&
info_file
);
while
(
FindNextFileA
(
h_find_file
,
&
info_file
)){
if
(
info_file
.
dwFileAttributes
==
FILE_ATTRIBUTE_DIRECTORY
){
dap_list_append
(
list
,
info_file
.
cFileName
);
}
}
FindClose
(
h_find_file
);
DAP_FREE
(
m_path
);
#else
DIR
*
dir
=
opendir
(
a_path_dir
);
struct
dirent
*
entry
=
readdir
(
dir
);
while
(
entry
!=
NULL
){
if
(
strcmp
(
entry
->
d_name
,
".."
)
!=
0
&&
strcmp
(
entry
->
d_name
,
"."
)
!=
0
&&
entry
->
d_type
==
DT_DIR
){
dap_list_append
(
list
,
entry
->
d_name
);
}
entry
=
readdir
(
dir
);
}
closedir
(
dir
);
#endif
return
list
;
}
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