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
0
votes
1 answer

Php opendir() gives warning when using GET

I have a problem with one of my PHP applications. I use the following block of code to include my functions into the application: // Opening the directory where the functions are located and reading the contents if (is_dir(__FDIR__)){ …
misterp
  • 1
  • 1
0
votes
2 answers

PHP (images folder) image Listing in Alphabetical Order?

I'm having problems with a PHP script trying to list images alphabetically. I need this urgently and I have not much knowledge of PHP. I was trying to use scandir() but I'm not succeeding. Thanks for your help!! Here is the code: function…
0
votes
1 answer

readdir() doesn't work properly for subdirectories

I have this function that uses readdir(). I use stat() to get info about the files that are in the directory I give as parameter. folder_name[] is actually the absolute path for the directory I want to read The function works fine for names like…
user3586734
0
votes
1 answer

Read files in a directory using readdir_r and sort using qsort

I am trying to write a program in C that reads files from a directory and detects the name, user, group, and size of each file. The information for each file is stored in a struct array and sorted by file name using qsort. The sorted files are…
Paddyngton
  • 55
  • 1
  • 8
0
votes
3 answers

save readdir into a buffer in C

I'm using readdir() to read to output all the files in a directory. The problem is that I need to save the strings into a buffer. Is there any way to save the output into a buffer or file descriptor etc? Here is my code: DIR *directory; struct…
user16655
  • 1,901
  • 6
  • 36
  • 60
0
votes
1 answer

Reading and selecting files using dirent.h in C

I'm new into programming microcontrollers, and I have a problem. I'm trying to make a device that plays music from USB. I can read from USB, but I have no idea how to choose a certain file. I'm using dirent. My code so far: while (true) { …
Scura
  • 1
  • 1
  • 3
0
votes
1 answer

retrieving attributes of files from a folder

I am doing an assignment that requires me to create a function similar to ls. My code works fine but when it comes to implementing the behaviour of ls -l child //where child is a folder there is a weird behaviour. Let's say i am in the folder…
winhung
  • 553
  • 1
  • 5
  • 19
0
votes
2 answers

Opening a folder with php and displaying the results in an html form?

I have a basic php admin system on a website. I can upload images normally but have to enter each dir location individually. I want to be able to type in the dir location and have the html form fields auto fill with the results from the folder. I…
0
votes
2 answers

Trying to sort out date based folder names in PHP

I have a folder structure like this Folder/ 09_06_2014/ Main Body/ page001.JPG Folder/ 03_06_2014/ Main Body/ page001.JPG Folder/ 09_07_2014/ Main Body/ page001.JPG What i'm trying to do is pick the picture…
DiZzY
  • 35
  • 6
0
votes
1 answer

Level 2 I/O in Linux using readdir() possible?

I am trying to traverse a directory structure and open every file in that structure. To traverse, I am using opendir() and readdir(). Since I already have the entity, it seems stupid to build a path and open the file -- that presumably forces…
Dov
  • 8,000
  • 8
  • 46
  • 75
0
votes
3 answers

C language, readdir and segmentation fault on running

This code give back a segmentatin fault when I try to run it Nothing appears wihle building the file with gcc If you have any Idea about where to search to fix it give your advise thanks. necessarly its in the function readrep() that must…
0
votes
2 answers

readdir group folders by first letter

I have a list of folders but want to group them by first letter ie all A folders together, all B folder together etc: $handle = opendir("."); $projectContents = ''; while ($file = readdir($handle)) { if (is_dir($file) &&…
Anna Riekic
  • 728
  • 1
  • 13
  • 30
0
votes
1 answer

PHP Script to retrieve filename as an achor tag

I can't work out how to write a PHP script that will iterate over a set of files in a folder (let's say, 3 MP3 files), output the filename and add anchor tags around this to provide a download link. I assume this is how I would begin but I have no…
0
votes
2 answers

PHP read files randomly

So I'm having little trouble, I would like to order randomly all the folders in order to display them in a grid, with thumbnails, so here's my code