Questions tagged [opendir]

A PHP, PERL, C library function for opening a directory handle. Questions are about the workings or issues with the opendir function.

The opendir() function is used to open up a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.

Links:

Related

262 questions
0
votes
1 answer

Return fixed number of items from a directory in reverse alphabetical order

I have files in directories that are labeled by date (eg, 2012-07-05.xls, 2012-07-04.xls) and I want only to list (and link) the last 10 files in that directory, starting with the newest one. I can generate the list easily in the proper order, but…
0
votes
3 answers

Opendir get array of files before files in sub folder

I have a function which returns an array of files in a folder recursive. protected function getFiles($base) { $files = array(); if(!is_dir($base)) return $files; if (($handle = opendir($base)) != false) { while (false…
John Magnolia
  • 16,769
  • 36
  • 159
  • 270
0
votes
1 answer

How to get glob() to return the same files order as opendir()?

I want glob to return same files order (sort) as opendir For example: $files = glob('/home/web/public_html/audio/*.mp3'); foreach($files as $file) { echo $file; break; } if ($handle = opendir('/home/web/public_html/audio/')) { while (false…
I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213
0
votes
1 answer

Opendir works only with absolute path

When using following code: if ($handle = opendir('../flat')) { } I'm getting this error: Warning: opendir(../flat) [function.opendir]: failed to open dir: No such file or directory in D:\Inetpub\webs\mysite\newSite\lib\flat.php on line…
Jayyrus
  • 12,961
  • 41
  • 132
  • 214
0
votes
1 answer

Wordpress don't redirect specific url

I've created a WP theme, which contains slideshows on different pages. I don't want to use any WP plugins for that specific project, so I tried the following: define foldes at the root directory (e.g. /slideshow/folder1) get files from folders on…
Andre
  • 77
  • 1
  • 10
0
votes
1 answer

how to skip a directory while reading using dirent.h

i am trying to recursively open files using the functionality provided in dirent.h My problem is: i could not make it to skip directories which failed to open. I want it to open the directories which it can and skip those which it can't and move to…
0
votes
2 answers

opendir error?

I get an error with this istruction: dp = opendir ("%APPDATA%/."); output: Couldn't open directory: Mo such file or directory. but I don't get an erro with this istruction: dp = opendir…
xRobot
  • 25,579
  • 69
  • 184
  • 304
0
votes
1 answer

New to , trying to access data in a directory

I've never used dirent.h before. I was using istringstream to read through text files (singular), but have needed to try to revise the program to read in multiple text files in a directory. This is where I tried implementing dirent, but it's not…
Heather Wilson
  • 153
  • 2
  • 4
  • 13
0
votes
1 answer

listing folders of parent directory with opendir does not work

The following script works fine for the current directory:
user1293977
  • 159
  • 9
-1
votes
1 answer

How to return folders that do not contain a certain file?

I'd like to filter out folders that do not contain poster.* (JPG/PNG/GIF) OR folder.* (JPG/PNG/GIF). I created the following code but I'm a bit clueless on how to do this efficiently:
FLX
  • 4,634
  • 14
  • 47
  • 60
-1
votes
1 answer

Listing PDF files in dir with PHP 7.2

The function below lists all PDF files in choosen directory. Also reads and print out the song title inside the PDF (they are all songs). The script works like a charm in PHP 5.6 but not in PHP 7.2. I have to upgrade to 7.2 because of my hosting…
-1
votes
1 answer

Seg. Fault and not sure why

I am not sure why I am getting a seg fault. I know it is somewhere in my pidspec function but I'm not sure why it is happening. The goal of this program is to have the process id passed in as first argument to program, from there, the pid is…
-1
votes
1 answer

How to access images or files from the network drive in PHP

I am trying to access image from network drive which is connected to my machine. But i am unable to access it using php. I mapped it using net use command still i am unable to accees it. Please help me out. if($fh=opendir('\\\\F:')) { while (false…
-1
votes
1 answer

readdir only gives dots - php

So, I have this function and for some reason, it only returns dots, while anywhere else it returns what it should function scan($dir){ $open = opendir($dir); $Name = readdir($open); return $Name; } scan('/home/user/scan/scan-test2'); I…
-1
votes
1 answer

C: Why I am getting a Segmentation Fault when trying to create a new folder/directory?

I am trying to create a new folder using two command line arguments, one being the destination folder and the other the source, but I am getting a "Segmentation fault (core dumped)" error. Could you please help me figure out what is causing this…
01eg
  • 1
1 2 3
17
18