Questions tagged [readdir]

The C, Perl or PHP library function for reading from an open directory.

The readdir C library function reads and returns the next entry, as a struct dirent *, from an open DIR *. You should open the directory using opendir first. This can also refer to the Perl or PHP functions with the same purpose.

Links:

301 questions
2
votes
1 answer

readdir() in linux sometimes not returning correct string utf8

I have a file in a folder with name as 01一千个伤心的理由 张学友 but sometimes readdir() is simply returning all ????????? as the name of the file. I searched for this on google and found that readdir has some utf-8 issue on some systems (like this one). Did…
Naveen
  • 7,944
  • 12
  • 78
  • 165
2
votes
2 answers

Allocating a struct dirent without malloc()

I need to use readdir_r() to read the contents of a directory in a multithreaded program. Since the size of struct dirent is filesystem dependent, man readdir_r recommends name_max = pathconf(dirpath, _PC_NAME_MAX); if (name_max == -1) …
EOF
  • 6,273
  • 2
  • 26
  • 50
2
votes
1 answer

C opendir and readdir and inode

I have saved my program in a folder where there are 5 files. Now I want to print the files inode numbers. Here's my program: #include #include #include #include #include #include…
David
  • 3,055
  • 4
  • 30
  • 73
2
votes
2 answers

How to sort the contents of a directory alphabetically with sub directorys appearing before normal files?

I need to sort the contents of a directory in ascending order (alphabetically). The directories must appear before files even if the directory's name would appear after a files name (alphabetically). The same way file explorers do, they list…
Akkad
  • 609
  • 1
  • 7
  • 14
2
votes
1 answer

What is the single dot and double dots in the return value of function readdir() in php

I've been confused with the concept which descriped in php.net for the function is_dir(),it says Tells whether the given filename is a directory (1)It checks whether the given parameter is a directory or not,when I give it a path,it returns true…
user2556058
  • 311
  • 4
  • 9
2
votes
1 answer

Selecting file to be edited

i have an application that is used to edit .txt files. the application is made up of 3 parts Displays contents of a folder with the files to be edited(each file is a link when clicked it opens on edit mode). writing in to a file. saving to…
user2362103
  • 65
  • 2
  • 10
2
votes
3 answers

how to deal with special characters in nodejs fs readdir function

I'm reading a directory in nodejs using the fs.readdir() function. You feed it a string containing a path and it returns an array containing all the files inside that directory path in string format. It does not work for me with special characters…
askmike
  • 1,900
  • 4
  • 21
  • 27
2
votes
1 answer

Return file directories in an array

I`m trying to create a function that reads a directory and returns all file's working directories in an array, but it is not working. I don`t know why the code doesn`t work, can you help me? $postsDirectory = "../posts/"; function listFiles() { …
2
votes
2 answers

readdir() showing non visible files

I am using readdir() in Ubuntu to display files and directories. The weird thing is readdir() displays some files starting with "dot", and some that end at ~ . But these files are not in my specified directory. What are these files? I was wondering…
Naruto
  • 1,710
  • 7
  • 28
  • 39
2
votes
0 answers

How to edit readdir function in fs/readdir.c to filter out specific files when ls is called?

Can someone tell me in which part of the following code the information about all the files that are present in a directory is present? I'm trying to filter out few files that are to be hidden when ls tries to list all the files in the…
2
votes
3 answers

Get each file within a directory in c on Windows

I am currently working on a C project where I need to scan a directory and get the file name for each file within that directory. The code needs to run on both Windows and Linux. I have the linux version using the following code. DIR *dp; int i =…
Boardy
  • 35,417
  • 104
  • 256
  • 447
1
vote
2 answers

Why does grep still include . and .. in my list of files even though it does not match the regex I give it?

What I am trying to do is get a collection of all UTF16 Unicode charts. I downloaded all pdf files from http://unicode.org/charts/PDF/ and decided to use perl to get rid of all of the special, or UTF32 charts with the following…
Evan C
  • 141
  • 10
1
vote
2 answers

PHP - Creating 'DYNAMIC' Directories For HTML5

So... I'm a mega noob when it comes to PHP, trying my best to learn but ITS NOT GOOD ENOUGH. Anyways, what I am attempting to do is set up 2 different 'dynamic' directories within a PHP echo structured to fit an HTML5 audio tag. - 1st directory for…
Terry
  • 675
  • 2
  • 9
  • 21
1
vote
6 answers

How do I read multiple directories and read the contents of subdirectories in Perl?

I have a folder and inside that I have many subfolders. In those subfolders I have many .html files to be read. I have written the following code to do that. It opens the parent folder and also the first subfolder and it prints only one .html file.…
User1611
  • 1,081
  • 4
  • 18
  • 27
1
vote
1 answer

Why is fs::read_dir() thread safe on POSIX platforms

Some Background Originally, Rust switched from readdir(3) to readdir_r(3) for thread safety. But readdir_r(3) has some problems, then they changed it back: Linux and Android: fs: Use readdir() instead of readdir_r() on Linux and Android Fuchsia:…
Steve Lau
  • 658
  • 7
  • 13