Questions tagged [closedir]

7 questions
19
votes
5 answers

Efficiently Traverse Directory Tree with opendir(), readdir() and closedir()

The C routines opendir(), readdir() and closedir() provide a way for me to traverse a directory structure. However, each dirent structure returned by readdir() does not seem to provide a useful way for me to obtain the set of pointers to DIR that I…
1
vote
0 answers

Closedir() dumps core in Ubuntu

I used a piece of code found here to check if a directory is empty or not. However, closedir() seems to cause a core dump on Ubuntu. Any ideas why? The directory exists. Opendir returns a handle and readdir is able to access the directory with that…
Hannu
  • 11,685
  • 4
  • 35
  • 51
0
votes
0 answers

closedir causing munmap_chunk(): invalid pointer?

So, I was doing an exercise that prevedes to open a directory and save his files to use them for other functions. The code is: int main() { printf("%sApro la cartella salvataggi%s\n", COL_YELLOW, COL_GRAY); int i = 0; int initsaves =…
Dacqu91
  • 3
  • 3
0
votes
2 answers

fork() is causing memory leak

When I try recursively traverse directories in fork.Fork causing memory leak.İf I do just fork everythink okey but when I called function in child process I see memory leak on valgrind.I think ,I close every directory.But valgrind says…
reddawn
  • 11
  • 6
0
votes
1 answer

closedir() causes changes in existing list's nodes

This is a simplified code of my function: myList* listFilesInDirectory(char* path) { DIR* dir = opendir(path); myList* list = createList(); struct dirent* entry; while ((entry = readdir(dir)) != NULL) { myNode* node =…
mrJoe
  • 500
  • 3
  • 13
0
votes
3 answers

closedir () causing core dumped

I have below lines in my code written in C on unix platform. Please let me know why I am getting core dumped in closedir() function. I could successfully opened the directory specified by path. if (opendir(MyDir) != NULL ) { …
Sachin
  • 20,805
  • 32
  • 86
  • 99
0
votes
3 answers

List all images in a directory not listing contents

I am using the following to list all of the jpg images in a directory, for some reason its not working though, I think some of my 's and .s may be in the wrong place, I think I have confused myself a bit :-S .
Iain Simpson
  • 8,011
  • 13
  • 47
  • 66