Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
12087a6c
Commit
12087a6c
authored
Nov 27, 2018
by
Celine Mercier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C, views: made 'view_exists' function public (now 'obi_view_exists')
parent
fbabbceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
65 deletions
+65
-65
src/obiview.c
src/obiview.c
+51
-65
src/obiview.h
src/obiview.h
+14
-0
No files found.
src/obiview.c
View file @
12087a6c
...
...
@@ -83,20 +83,6 @@ static char* build_obiview_file_name(const char* view_name);
static
char
*
build_unfinished_obiview_file_name
(
const
char
*
view_name
);
/**
* Internal function checking if a view (either finished or unfinished) with a given name already exists in a DMS.
*
* @param dms The DMS.
* @param view_name The name of the view.
*
* @returns A boolean value indicating whether the view already exists or not.
*
* @since September 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
static
bool
view_exists
(
OBIDMS_p
dms
,
const
char
*
view_name
);
/**
* Internal function checking if a view is finished.
*
...
...
@@ -553,55 +539,6 @@ static char* build_unfinished_obiview_file_name(const char* view_name)
}
static
bool
view_exists
(
OBIDMS_p
dms
,
const
char
*
view_name
)
{
struct
dirent
*
dp
;
char
*
file_name
;
// Check finished views
// Create file name
file_name
=
build_obiview_file_name
(
view_name
);
if
(
file_name
==
NULL
)
return
-
1
;
rewinddir
(
dms
->
view_directory
);
while
((
dp
=
readdir
(
dms
->
view_directory
))
!=
NULL
)
{
if
((
dp
->
d_name
)[
0
]
==
'.'
)
continue
;
if
(
strcmp
(
dp
->
d_name
,
file_name
)
==
0
)
{
free
(
file_name
);
return
true
;
}
}
free
(
file_name
);
// Check unfinished views
// Create file name
file_name
=
build_unfinished_obiview_file_name
(
view_name
);
if
(
file_name
==
NULL
)
return
-
1
;
rewinddir
(
dms
->
view_directory
);
while
((
dp
=
readdir
(
dms
->
view_directory
))
!=
NULL
)
{
if
((
dp
->
d_name
)[
0
]
==
'.'
)
continue
;
if
(
strcmp
(
dp
->
d_name
,
file_name
)
==
0
)
{
free
(
file_name
);
return
true
;
}
}
free
(
file_name
);
return
false
;
}
static
int
view_is_finished
(
OBIDMS_p
dms
,
const
char
*
view_name
)
{
struct
dirent
*
dp
;
...
...
@@ -1557,6 +1494,55 @@ static int view_check_all_predicates(Obiview_p view, bool write)
**********************************************************************/
bool
obi_view_exists
(
OBIDMS_p
dms
,
const
char
*
view_name
)
{
struct
dirent
*
dp
;
char
*
file_name
;
// Check finished views
// Create file name
file_name
=
build_obiview_file_name
(
view_name
);
if
(
file_name
==
NULL
)
return
-
1
;
rewinddir
(
dms
->
view_directory
);
while
((
dp
=
readdir
(
dms
->
view_directory
))
!=
NULL
)
{
if
((
dp
->
d_name
)[
0
]
==
'.'
)
continue
;
if
(
strcmp
(
dp
->
d_name
,
file_name
)
==
0
)
{
free
(
file_name
);
return
true
;
}
}
free
(
file_name
);
// Check unfinished views
// Create file name
file_name
=
build_unfinished_obiview_file_name
(
view_name
);
if
(
file_name
==
NULL
)
return
-
1
;
rewinddir
(
dms
->
view_directory
);
while
((
dp
=
readdir
(
dms
->
view_directory
))
!=
NULL
)
{
if
((
dp
->
d_name
)[
0
]
==
'.'
)
continue
;
if
(
strcmp
(
dp
->
d_name
,
file_name
)
==
0
)
{
free
(
file_name
);
return
true
;
}
}
free
(
file_name
);
return
false
;
}
Obiview_p
obi_new_view
(
OBIDMS_p
dms
,
const
char
*
view_name
,
Obiview_p
view_to_clone
,
index_t
*
line_selection
,
const
char
*
comments
)
{
Obiview_p
view
;
...
...
@@ -1582,7 +1568,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
}
// Check uniqueness of name
if
(
view_exists
(
dms
,
view_name
))
if
(
obi_
view_exists
(
dms
,
view_name
))
{
obi_set_errno
(
OBIVIEW_ALREADY_EXISTS_ERROR
);
obidebug
(
1
,
"
\n
Name of new view ('%s') already exists"
,
view_name
);
...
...
@@ -2872,7 +2858,7 @@ int obi_delete_view(OBIDMS_p dms, const char* view_name)
int
finished_view
;
// Check that the view exists
if
(
view_exists
(
dms
,
view_name
)
==
false
)
if
(
obi_
view_exists
(
dms
,
view_name
)
==
false
)
{
obi_set_errno
(
OBIVIEW_ERROR
);
obidebug
(
1
,
"
\n
Error trying to delete a view: view '%s' does not exist"
,
view_name
);
...
...
src/obiview.h
View file @
12087a6c
...
...
@@ -138,6 +138,20 @@ typedef struct Obiview {
}
Obiview_t
,
*
Obiview_p
;
/**
* Function checking if a view (either finished or unfinished) with a given name already exists in a DMS.
*
* @param dms The DMS.
* @param view_name The name of the view.
*
* @returns A boolean value indicating whether the view already exists or not.
*
* @since September 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
bool
obi_view_exists
(
OBIDMS_p
dms
,
const
char
*
view_name
);
/**
* @brief Creates a new view.
*
...
...
Write
Preview
Markdown
is supported
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