opendir

Open directory using C

浪子不回头ぞ 提交于 2019-12-17 10:58:11
问题 I am accepting the path through command line input. When I do dir=opendir(args[1]); it doesn' t enter the loop...i.e dir==null ... How do I pass the command line input to dir pointer? void main(int c,char **args) { DIR *dir; struct dirent *dent; char buffer[50]; strcpy(buffer, args[1]); dir = opendir(buffer); //this part if(dir!=NULL) { while((dent=readdir(dir))!=NULL) printf(dent->d_name); } close(dir); } ./a.out /root/TEST is used to run the program.. ./a.out --> to execute the program

Path to a file in a different drive?

a 夏天 提交于 2019-12-12 13:59:20
问题 My php file is here: D:/Appserv/www/x/y/file.php I want to load stuff from this folder: E:/foldie I don't know what path will lead me there. $somePath="HELP ME HERE!!!!" $dir=opendir($somePath); //looping through filenames while (false !== ($file = readdir($dir))) { echo "$file\n"; } 回答1: Use full Windows path to the file it should be working: "E:\folder\file.txt" or just copy the file in the local/project directory for testing purpose. 回答2: Set $somePath = "e:\\foldie" . If that doesn't work

C manipulate directories : how to position at a directory by giving its name in main arguments

吃可爱长大的小学妹 提交于 2019-12-11 19:42:50
问题 I'm having trouble to manipulate directories in C. I want to give the name of 2 directories as argument on main check if the first directory exists (in the current path) open the directory call a function (that i created) to create files and do stuff inside the directory close the directory and go into the 2nd directory and do the same . I wrote my code but it still not doing the stuffs inside the directories that i gave on main, instead it looks like i'm always positioned in the current

opendir: Too many open files

…衆ロ難τιáo~ 提交于 2019-12-11 05:14:31
问题 I write this code to print all files in /home/keep with absolution path: #include <dirent.h> #include <sys/stat.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> void catDIR(const char *re_path); int main(int argc, char *argv[]) { char *top_path = "/home/keep"; catDIR(top_path); return 0; } void catDIR(const char *re_path) { DIR *dp; struct stat file_info; struct dirent *entry; if ((dp = opendir(re_path)) == NULL) { perror("opendir"); return

Printing off_t file size from dirent struct

折月煮酒 提交于 2019-12-11 03:35:34
问题 All i want is to print the size of a file in bytes I am using DIR *d; struct dirent *dir; d= opendir(absolute_path); while((dir= readdir(d))!=NULL){ printf("%s\t %d\t %u\n",dir->d_name,dir->d_type,(int long long )dir->d_off); } The printing of the d_off that is type off_t is wrong. For a file of 323,388 bytes it prints 1296623584 I think that the casting is the problem. I tried lots of castings such as %d , %s , %u , %llu ... What is the right casting? EDIT: The right function to use to find

php - opendir, force listing hidden files (ftp)

跟風遠走 提交于 2019-12-08 07:51:02
问题 How to force listing hidden files with ftp connection in PHP script? Is there any context option for opendir? Thanks 回答1: "ftp_rawlist — Returns a detailed list of files in the given directory" (raw => ALL incl. hidden) https://secure.php.net/manual/en/function.ftp-rawlist.php There is one comment to the ftp_rawlist: Get a listing of all files including hidden files except '.' or '..' use: <?php ftp_chdir($connid, $dir); ftp_rawlist($connid, "-A"); ?> This had me dancing in circles for some

php - opendir, force listing hidden files (ftp)

筅森魡賤 提交于 2019-12-07 15:57:25
How to force listing hidden files with ftp connection in PHP script? Is there any context option for opendir? Thanks Quicker "ftp_rawlist — Returns a detailed list of files in the given directory" (raw => ALL incl. hidden) https://secure.php.net/manual/en/function.ftp-rawlist.php There is one comment to the ftp_rawlist : Get a listing of all files including hidden files except '.' or '..' use: <?php ftp_chdir($connid, $dir); ftp_rawlist($connid, "-A"); ?> This had me dancing in circles for some time! 来源: https://stackoverflow.com/questions/23346935/php-opendir-force-listing-hidden-files-ftp

Opendir error; No such file or directory found

亡梦爱人 提交于 2019-12-05 14:26:38
This may be a very easy question. I am working in directory /mobile and I have photos in a directory /uploads. I am getting the error: Warning: opendir(http://www.yoozpaper.com/uploads) [function.opendir]: failed to open dir: not implemented in /hermes/bosweb/web088/b881/ipg.yoozpapercom/mobile/sportspage.php on line 313 I am putting this into a variable $dir = "http://www.yoozpaper.com/uploads" for the image src=$dir/$file . Note that this is working when I am working with files in the main directory. Any help on this would be greatly appreciated. Code below: $dir = "http://www.yoozpaper.com

Delete files from a specific folder in C

巧了我就是萌 提交于 2019-12-04 06:15:58
问题 I'm trying to delete files from a specifc folder. My deleteFile() function only deletes on its home folder, not on /tmp folder which is what I need. I tried the same approach as my displayDIR() function to change directory but I can't figure out how to make it work. I use cygwin as compiler. void deleteFile() { int status; char filetodelete[25]; printf("\n \t **Delete File**\n"); displayDIR(); printf("\n\tChoose the name of the file to delete:\t"); scanf("%s", filetodelete); status = remove

List all files in a directory ,extra information is coming

你说的曾经没有我的故事 提交于 2019-12-02 15:59:04
问题 here my code- if ($handle = opendir('banner/')) { while (false !== ($file = readdir($handle))) { echo "$file"; } closedir($handle); } wher I run this code unnecessary dots(.) are coming. output image-3.jpgimage-4.jpgimage-1.jpgimage-2.jpgimage-5.jpg... why 3 dots are coming at the last?? 回答1: Because . is the current directory and .. is the parent directory. They are always exists. If you need to exclude them - just add if ($file != '.' && $file != '..') right before echo 回答2: It's because