Skip to content

Commit

Permalink
Remove unused path_stack c functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Aug 8, 2024
1 parent be89d65 commit ae289be
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 42 deletions.
2 changes: 0 additions & 2 deletions lib/include/ert/util/path_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ typedef struct path_stack_struct path_stack_type;
path_stack_type *path_stack_alloc();
void path_stack_pop(path_stack_type *path_stack);
void path_stack_push_cwd(path_stack_type *path_stack);
bool path_stack_push(path_stack_type *path_stack, const char *path);
void path_stack_free(path_stack_type *path_stack);
int path_stack_size(const path_stack_type *path_stack);

#ifdef __cplusplus
}
Expand Down
22 changes: 0 additions & 22 deletions lib/util/path_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ path_stack_type *path_stack_alloc() {

void path_stack_free(path_stack_type *path_stack) { delete path_stack; }

/**
This will push a path on to the stack. The function will start by
chdir() to the input path. If the chdir() call fails the function
will return false, and the stack will be unmodified; if the chdir()
succeeds the input @path will be pushed onto the stack.
If path is NULL that is interpreted as cwd.
*/

bool path_stack_push(path_stack_type *path_stack, const char *path) {
if (path != NULL)
if (util_chdir(path) != 0)
return false;

path_stack_push_cwd(path_stack);
return true;
}

void path_stack_push_cwd(path_stack_type *path_stack) {
char *cwd = util_alloc_cwd();
path_stack->stack.push(cwd);
Expand All @@ -74,7 +56,3 @@ void path_stack_pop(path_stack_type *path_stack) {

path_stack->stack.pop();
}

int path_stack_size(const path_stack_type *path_stack) {
return path_stack->stack.size();
}
18 changes: 0 additions & 18 deletions lib/util/tests/ert_util_path_stack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,10 @@ int main(int argc, char **argv) {

path_stack_push_cwd(path_stack);

if (path_stack_push(path_stack, "NotExist-1111"))
test_error_exit("Pushed unexisting path\n");

if (!path_stack_push(path_stack, path1))
test_error_exit("Failed to push:%s \n", path1);

util_chdir(path2);
if (util_is_cwd(path1))
test_error_exit("Failed to chdir(%s) \n", path2);

if (path_stack_size(path_stack) != 2)
test_error_exit("Wrong stack size");

path_stack_pop(path_stack);
if (!util_is_cwd(path1))
test_error_exit("path_stack_pop failed \n");
Expand All @@ -38,15 +29,6 @@ int main(int argc, char **argv) {
if (!util_is_cwd(cwd))
test_error_exit("path_stack_pop failed \n");

if (path_stack_size(path_stack) != 0)
test_error_exit("Wrong stack size");

if (!path_stack_push(path_stack, NULL))
test_error_exit("Hmmm - push(NULL) failed \n");

if (path_stack_size(path_stack) != 1)
test_error_exit("Wrong stack size");

path_stack_pop(path_stack);
path_stack_free(path_stack);
}
Expand Down

0 comments on commit ae289be

Please sign in to comment.