stat

filesize(): stat failed for specific path - php

爱⌒轻易说出口 提交于 2021-02-18 20:15:26
问题 i am coding a simple doc managing script and need to get the file size and file type /file or folder/ in a table. somehow it doesn't work into the mention directory. please help if possible: <?php $path = "./documents"; $dh = dir($path); while( ($file=$dh->read()) ) { if( $file=="." || $file=="..")continue; echo "<tr><td><a href='download.php?f=$file' title='Click to Open/Download'>$file</a></td>"; echo "<td>"; echo (is_file($file))? "<img src='file.jpg'/> FILE" : "<img src='folder.jpg'/>

filesize(): stat failed for specific path - php

眉间皱痕 提交于 2021-02-18 20:12:05
问题 i am coding a simple doc managing script and need to get the file size and file type /file or folder/ in a table. somehow it doesn't work into the mention directory. please help if possible: <?php $path = "./documents"; $dh = dir($path); while( ($file=$dh->read()) ) { if( $file=="." || $file=="..")continue; echo "<tr><td><a href='download.php?f=$file' title='Click to Open/Download'>$file</a></td>"; echo "<td>"; echo (is_file($file))? "<img src='file.jpg'/> FILE" : "<img src='folder.jpg'/>

Better assertEqual() for os.stat(myfile).st_mode

偶尔善良 提交于 2021-02-10 08:44:04
问题 I have a code that checks the st_mode of a file: self.assertEqual(16877, os.stat(my_directory).st_mode) Only old school unix experts are able to decipher the integer value 16877 fluently. Is there more readable way to check for exactly this value? 回答1: If I may extend the question a bit and understand it as “Is there more readable way to check file modes?”, then I'll suggest adding a custom assertion. The target: self.assertFileMode(my_directory, user="rwx", group="rx", others="rx") How to do

Better assertEqual() for os.stat(myfile).st_mode

我与影子孤独终老i 提交于 2021-02-10 08:43:41
问题 I have a code that checks the st_mode of a file: self.assertEqual(16877, os.stat(my_directory).st_mode) Only old school unix experts are able to decipher the integer value 16877 fluently. Is there more readable way to check for exactly this value? 回答1: If I may extend the question a bit and understand it as “Is there more readable way to check file modes?”, then I'll suggest adding a custom assertion. The target: self.assertFileMode(my_directory, user="rwx", group="rx", others="rx") How to do

lstat: can't access files in another directory

你说的曾经没有我的故事 提交于 2021-02-05 08:09:31
问题 I'm trying to write ls-alike program that produces output like ls -l with permissions, owners, time and name of the file. It works good if I pass . (or nothing), so it works with the current directory. But if I pass any other directory in or out of the current one, perror says it "can't access" the files. Please, help me figure out what prevents lstat from accessing files in another dirs. I use gcc and a text editor, no IDE, started learning to use gdb (tried to debug but didn't find

Difference between lstat fstat and stat in C

馋奶兔 提交于 2021-01-20 16:26:42
问题 Im writing a school assignment in C to search through a file system for directories, regular files and symlinks. For now i use lstat to get information about items. So whats the difference between lstat fstat and stat system calls? 回答1: I was also searching for stat vs lstat vs fstat and although there is already an answer to this question, I'd like to see it formatted like that: lstat() is identical to stat() , except that if pathname is a symbolic link, then it returns information about the

Difference between lstat fstat and stat in C

 ̄綄美尐妖づ 提交于 2021-01-20 16:21:06
问题 Im writing a school assignment in C to search through a file system for directories, regular files and symlinks. For now i use lstat to get information about items. So whats the difference between lstat fstat and stat system calls? 回答1: I was also searching for stat vs lstat vs fstat and although there is already an answer to this question, I'd like to see it formatted like that: lstat() is identical to stat() , except that if pathname is a symbolic link, then it returns information about the

Difference between lstat fstat and stat in C

廉价感情. 提交于 2021-01-20 16:20:26
问题 Im writing a school assignment in C to search through a file system for directories, regular files and symlinks. For now i use lstat to get information about items. So whats the difference between lstat fstat and stat system calls? 回答1: I was also searching for stat vs lstat vs fstat and although there is already an answer to this question, I'd like to see it formatted like that: lstat() is identical to stat() , except that if pathname is a symbolic link, then it returns information about the

stat命令输出结果中, Access,Modify,Change的含义

为君一笑 提交于 2021-01-10 12:50:05
先建立一个空白文件a.txt [emduser@emd tmp]$ touch a.txt [emduser@emd tmp]$ ls -al a.txt -rw-rw-r-- 1 emduser emd 0 Dec 14 16:44 a.txt 利用stat命令查看文件a.txt的各种属性 [emduser@emd tmp]$ stat a.txt File: `a.txt' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 654176 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 501/ emduser) Gid: ( 506/ emd) Access: 2011-12-14 16:44:23.000000000 +0800 Modify: 2011-12-14 16:44:23.000000000 +0800 Change: 2011-12-14 16:44:23.000000000 +0800 上述最后三行的含义如下: Access : 文件 最近一次被访问 的时间 Modify: 文件 内容最近一次被修改 的时间 Change: 文件 属性最近一次被改变 的时间 假如用cat命令将文件a.txt的内容输出到终端( 执行

same date when printing from st_mtime, st_ctime,st_atime

非 Y 不嫁゛ 提交于 2020-12-12 09:53:09
问题 So, I'm supposed to print the date of access of directories, modification and creation, but they all seem to be the same date. Here's my code: struct* tm date; struct stat fileStat; if(options[0] == 1 && options[1] == 0 && options[2] == 0 && options[3] == 0){ date = localtime(&(fileStat.st_mtime)); printf("M%02i/%d/%i-%02d:%02d", date->tm_mon,date->tm_mday, (date->tm_year + 1900)%100, date->tm_hour,date->tm_min); date = NULL; } else if(options[0] == 1 && options[1] == 1 && options[2] == 0 &&