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
4
votes
2 answers

PHP: Safe way to remove a directory?

Consider this code: public static function removeDir($src) { if (is_dir($src)) { $dir = @opendir($src); if ($dir === false) return; while(($file = readdir($dir)) !== false) { if ($file != '.' &&…
Dalius
  • 726
  • 1
  • 8
  • 19
3
votes
1 answer

Linux, C: access() not catching permission problems, or something

I am writing a program to mimic some of the behavior of find that walks a directory tree and calls lstat on the files it finds there to determine their type. The real find will ignore files where the user does not have R or X access in that…
Sabrina S
  • 337
  • 8
  • 21
3
votes
2 answers

"Double dot" directory name in C?

I'm writing a program for class, and I'm wondering about the output for a bit of code. I have some code like this: DIR* dir = opendir("."); struct dirent* reader; while ((reader = readdir(dir)) != NULL) { //print the name of the path found by…
noob-see
  • 33
  • 3
3
votes
1 answer

Behavior of opendir() after removing a directory with rmdir()

I'm trying to understand how removing the current working directory works from a C program. I'm using the Advanced Programming in Unix Enviroment book as a reference. First, I make the following sequence of calls (/tmp is an existing directory): //…
3
votes
1 answer

Segfault with readdir()

I'm just starting with C programming, and i'm trying to read and display files in a directory (just like the ls command). Here's a part of my code where I get a segfault, and I have no clue why: void display_dir(char *dir) { DIR *strm; …
ChypRiotE
  • 285
  • 4
  • 11
3
votes
1 answer

Access Files from different domains using php

I have PDF documents stored in a shared folder in a server where I need to access them from a web application through file browsing. I know the names of the files stored there. So my link would be like (file:\\server\folder\abc.pdf). My php…
Guns
  • 2,678
  • 2
  • 23
  • 51
2
votes
1 answer

Sort opendir In Alphabetical Order

Is it possible to sort opendir into althabetical order? $user = $fgmembersite->UserFullName(); $handle = opendir("users/$user/"); while (false!==($file = readdir($handle))) { if ($file != "." && $file != ".."){ echo 'some code here'; …
Josh
  • 2,835
  • 1
  • 21
  • 33
2
votes
1 answer

Can opendir(pathname) change the value of the input pathname?

I've received some curious results while using opendir(): int dtw(char *path) { struct stat statbuf; ... else if (S_ISDIR(statbuf.st_mode)) { printf("Path is: %s\n", path); struct dirent *dirent; …
Cody
  • 135
  • 1
  • 3
  • 11
2
votes
1 answer

Scanning a directory and modify file in c

I'm trying to create a function that scans a folder on my Windows PC and every time it does, a file called "Filter.txt" is appended with the string "Test Script". Now the problems are 2, the first is that the scan must be performed either in the…
AleMal
  • 1,977
  • 6
  • 24
  • 49
2
votes
1 answer

How to sort a list of files build up with PHP opendir() and hide extensions?

As I only get one very very tiny part of the PHP phenomenon I'm very happy that I managed to create the following script by searching the web. As you can see, this shows the files present in the folder 'archive' on the website I'm building. It's for…
Stijn
  • 103
  • 1
  • 4
  • 14
2
votes
1 answer

Segmentation fault with opendir()?

I can't get to know why do I keep getting this segmentation fault in this function Could anyone enlighten me about how to get rid of it and get my program to work...? Lign 33 : flux = opendir(path); Lign 98 : ret = listdir(env, stock, pos,…
Slrs
  • 105
  • 1
  • 3
  • 11
2
votes
2 answers

Nodejs "closing directory handle on garbage collection"

Нello, the following is an excerpt from my code: let dirUtility = async (...args) => { let dir = await require('fs').promises.opendir('/path/to/some/dir...'); let entries = dir.entries(); for await (let childDir of dir)…
Gershom Maes
  • 7,358
  • 2
  • 35
  • 55
2
votes
0 answers

opendir on IIS10 and PHP 8

I have recently been setting up a corporate server to put my website online. Previously this website was hosted on my pc using XAMPP with PHP 5; now I have Windows Server 2019 and PHP 8. Everything works, but something is wrong in opendir() and…
2
votes
0 answers

PHP opendir Fails when reading from Windows path to Linux server

I am running Apache on a Linux server, I have an application mounted there that needs to read a directory from the enduser computer to copy some files, the problem is that the users work with Windows, all the app works fine but when trying the…
Ektoer
  • 31
  • 2
2
votes
3 answers

Ignore hidden files with php

I am trying to scan a folder of images, however I keep seeing the ._ files the mac created I am using this code:
mattyb
  • 194
  • 3
  • 12
1
2
3
17 18