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

check filesystem file consistency against db

I have a PHP script that uploads files to a directory on my filesystem. On the same time I store the filename in a field on a MYSQL DB. I have seen that I have more files than records in the db. What's the shortest way to find out and delete all…
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
0
votes
2 answers

Folders Tree in php

I want to list the contents of a folder in php. But i would like to display only the folder and not the files. In addition, i would like to display a maximum of one sub-folder! Could you help me please ! My code :
GilbertOOl
  • 1,299
  • 2
  • 15
  • 27
0
votes
1 answer

Directory traversal application (readdir_r and stat) fails silently on exception

I've implemented walk through directory hierarchy using 'readdir_r', it works as expected when I pass my function a string ending with '/' symbols, for example: "./../../". But when I pass something like "./.." the program fails silently though it…
Arks
  • 569
  • 5
  • 19
0
votes
2 answers

PHP opendir and readdir with array directories (not one)

I have this problem, I want to use opendir with this array of directories, it is possible? with a fixed url I can read files with readdir. But I dont know what to do with multiple directories... Creating the array: $results =…
santyas
  • 96
  • 1
  • 2
  • 12
0
votes
1 answer

Readdir images from subdirectories and SORT alphabetically?

i found this code (https://stackoverflow.com/a/9628457/1510766) for show all images from directories and sub-directories, and works fine, but im trying to implement the sort() function of php but doesnt work: function ListFiles($dir) { …
santyas
  • 96
  • 1
  • 2
  • 12
0
votes
1 answer

How to distinguish between files and directories using ssh2 on a remote server

We are attempting to move only the files from a remote server and putting the files directories into our database, so we need to be able to distinguish between a file and a directory. We have successfully been able to connect via SSH2 and we are…
ggSmith
  • 5
  • 3
0
votes
1 answer

Codeigniter read from directory failed

I changed and now it does not show nothing. The directories exist on the folder. i am giving you an example. If i echo $dir i get fullurlpath/root_folder/username the whole path and directories exist so the $dir is ok, something else must happend.…
DanielDake
  • 25
  • 1
  • 10
0
votes
1 answer

news ordering by file name from files in directory

I need my script to sort the .txt files by date. it's like a simple news script, what i do is adding .txt files named: [23.7.13] New cool title [24.7.13] advices and tips and echo the contents, already have everything ready including the echo…
0
votes
2 answers

how to hide a file from readdir() php

My code loops through a directory and displays all the files and folders where I have a index.php file that I don't want to be displayed.
user1928251
0
votes
1 answer

php filename encoding, ö is no real ö or what is "o ̈ "?

i'm uploading images into a little cms on my php server, and now i have a file called "1372609671-Terrassenböden Watrawood.jpg" which causes some serious problems. i have downloaded everything to my mac and debugged everything down... facing…
jebbie
  • 1,418
  • 3
  • 17
  • 27
0
votes
1 answer

perl readdir not listing all files

I am having problems with readdir not actually reading all the files in a given folder. I am seeing only the following three files and a folder: main.cpp main.hpp imageLoader.hpp util whilst, if I use bash ls -lat I get following files…
thecoshman
  • 8,394
  • 8
  • 55
  • 77
0
votes
1 answer

Indexing folders: Not detecting a directory

back to /

'; } foreach(scandir('files'. $dir) as $filename){ if($filename…
Thew
  • 15,789
  • 18
  • 59
  • 100
0
votes
1 answer

Trying to read files from a directory into PHP script

I've been trying to get my php script to read a directory for specific files and run the script on each, but I can't get it to work. I keep getting an error failed to open directory. I'm wondering if there is a small mistake I've made, and I've been…
ValleyDigital
  • 1,460
  • 4
  • 21
  • 37
0
votes
1 answer

How to read multiple files from directory and run the script on each file

I'm having difficulty with this problem. I have created a PHP script that pulls data from a .mov file, parses it, and then outputs only the data that I want. Now, my problem is that I have to do this for 80+ files, and I was wondering how can I read…
ValleyDigital
  • 1,460
  • 4
  • 21
  • 37
0
votes
1 answer

Why readdir returns null and I/O error the next call to readdir after first call on a directory

DIR *dir_ptr; struct dirent *dir_entery; dir_ptr = opendir("/tmp"); while (dir_ptr&&(dir_entery = readdir(dir_ptr))) { printf("%s \n", dir_entery->d_name); } printf("%s \n", strerror(errno)); gives this output: file_name dir_name errno =…
0x90
  • 39,472
  • 36
  • 165
  • 245