Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
3 answers
122 views

How can I detect an existing directory in ~/ with stat in C?

If the directory ~/testdir not exists, I want to create it. Before the test, I create the directory ~/testdir, but stat is not detecting it, and the program tries to create it once more. I only has ...
Eddy Sorngard's user avatar
0 votes
1 answer
282 views

how to get directory size with flutter?

I'm using flutter and I want to know the capcity size of a directory. this is my code : final String directory = (await getApplicationSupportDirectory()).path; My question is how to get directory ...
ASMA's user avatar
  • 89
2 votes
2 answers
226 views

Differentiating between files and directories on linux in C

I have a function that takes in an argument which is a file path. That path is then used in conjunction with the readdir function and stat function to print out all of the files and directories in a ...
Devin Bowen's user avatar
-1 votes
1 answer
1k views

directory listing C (using dirent and stat)

Im making a directory listing application that prints a directory listing just like the ’ls’ and ’dir’ commands in Linux and Windows respec- tively. my function: prints a listing of all files in the ...
bizariuz's user avatar
0 votes
2 answers
3k views

stat() function only works in the current directory C language

i'm using C on windows to read the contents of a directory and info about each entry, however the stat() function only works if i opened the current directory "." directory = opendir(".") whenever ...
AX360's user avatar
  • 11
2 votes
2 answers
3k views

how to check if any of the files in a directory changed

Given a directory, I'd like to know whether the files in the directory have been modified or not. (Boolean) i.e. if the directory's state has changed from before. I don't want to run a file watcher ...
Phani Rithvij's user avatar
0 votes
1 answer
740 views

stat using S_ISDIR Don't seem to always work

I've noticed something strange in the output of my function (in c). This function detect in a directory if an element is a file or a subdirectory. // i cant detected properly if an element is a file ...
Lynn's user avatar
  • 121
0 votes
3 answers
2k views

stat() giving wrong information

I'm using a loop to print the information of each file in a directory to recreate the ls shell function as a C program. When comparing the information from the program to the correct information from ...
stevennash's user avatar
1 vote
0 answers
871 views

How to handle os.stat() permission issue? (Python 2.7)

I'm trying to create a subdirectory if it doesn't already exist. Here is the relevant portion of my function (TMP is the constant "-InProg"): def create_directories(parent, tmp_dir=""): """ ...
B. Shefter's user avatar
0 votes
0 answers
98 views

python ctime of a directory referenced by a symbolic link

we have a directory directory and a symlink pointing to it symlink -> directory. Symlink is updated periodically (recreated) but the directory is updated much less often. Problem: find out what ...
user6831474's user avatar
0 votes
1 answer
512 views

accessing dictionary-stats in Ansible

I want to take action on a folder, if its empty. So I try to use conditionals on folders-stats. The folders are created with a dictionary. - name: Statistics of folder stat: path=/srv/svn/{{ ...
pwe's user avatar
  • 127
0 votes
1 answer
762 views

Recursive listing of directories and files C

My C code for recursively listing directories and files get executed multiple times. I am not sure how to fix it and why it keeps happening... It is not infinite its just like 10 times shows the ...
Anastasia Netz's user avatar
0 votes
1 answer
235 views

My ls -R doesn't work

Having issues with my ls -R implemented in C. When I run the program with command ./myls -R nothing displays, all blank:(Help needed. int print_Recursive(char *dirname) { char fbuf [256]; DIR *dir; ...
Anastasia Netz's user avatar
0 votes
2 answers
427 views

Viewing attributes of a file with stat (C)

#include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> int main(int argc, char** argv) { ...
4oursword's user avatar
0 votes
2 answers
3k views

stat() doesn't work on parent directory

I'm trying to code the ls command in C, but stat() refuse to open any other directory. ~/Desktop/ls$ cat bug.c #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #...
raph77777's user avatar
  • 111
0 votes
1 answer
442 views

Passing a dir as argument and show its last modified date

OK, so I was thinking of a program that displays my folder's or file's last modified time; I succeeded doing that, but I passed only the path as argument. #include <stdio.h> #include <time.h&...
mariuss's user avatar
  • 1,247
0 votes
1 answer
1k views

C struct stat info not updating in a loop, giving ridiculous modification date

For one part of a code, I need to save both the name and the stats (user ID, group ID, modification time, permissions, etc.) of every file in a given directory into an array of self-defined structs. ...
jiccan's user avatar
  • 89
0 votes
1 answer
560 views

stat function returns empty struct [duplicate]

studentsDir = opendir(lineValues); while ((entry = readdir(studentsDir)) != NULL) { stat(path, &dirData); if (S_ISDIR(dirData.st_mode) && (entry->d_name[0] != '.') &...
user2740785's user avatar
1 vote
1 answer
845 views

list directory and display details of each file. owner, octal permissions and filename using c

I'm trying to create a method that will do some system calls. It should display the owner of and octal code of each file. but somehow I cant get going. It displays the logged in user name as owner of ...
Tad Lithuania's user avatar
1 vote
1 answer
8k views

C programming: How to get directory name?

I'm writing a code for printing out the path from root to current directory or referred directory, using recursive function. but I can't get the directory name, only get .. Problem happened among base ...
LuckyLast's user avatar
1 vote
1 answer
6k views

ERROR: stat: No Such File Or Directory, opendir() and stat() in C programming

Hey and thanks for reading. I am making a program which takes 1 argument (directory) and reads all the files in the directory used opendir()/readdir(), and displays the file type (reg, link, ...
Barney Chambers's user avatar
5 votes
1 answer
2k views

Get a sorted list of folders based on modification date

I am trying to figure out how to apply a Python function to the oldest 50% of the sub-folders inside my parent directory. For instance, if I have 12 folders inside a directory called foo, I'd ...
stratis's user avatar
  • 8,022
2 votes
2 answers
8k views

How to get total size of a folder in C with recursivity?

All the folders have the size 4096 B. How do I get the total size of a folder with all the file size inside? For example: > Dir1 (4096) > -- File1.txt (100) > -- Dir 2 (4096) > ---- ...
Lord Rixuel's user avatar
  • 1,233
0 votes
1 answer
158 views

How to hide . and .. folders in C?

I'm trying to list all folders and all files of a folder with the language C. This is the following code: #include <errno.h> #include <stdio.h> #include <dirent.h> #include <sys/...
Lord Rixuel's user avatar
  • 1,233
0 votes
1 answer
72 views

reading directories in C 2.0 stat error

I want to list the archives in a directory, and it works. The problem is if I am in "." and i want to list te files inside "./hello" since ".", (ls -l hello) for example. The problem is that I dont ...
user3240579's user avatar
0 votes
1 answer
4k views

Perl directory exists equivalent of -e

-e File exists. is there one for directory exists? because i didnt see it on http://perldoc.perl.org/functions/-X.html Or what would be a best way to test it? next unless (-e $dir . "/dirname"); ...
ealeon's user avatar
  • 12.4k
1 vote
1 answer
2k views

List files and their info using stat

I am programming an ftp server using c++ and I need to be able to get all info about files in form of : sent: drwxr-xr-x 1000 ubuntu ubuntu 4096 May 16 11:44 Package-Debug.bash so I can send it to ...
user2274361's user avatar
2 votes
4 answers
7k views

Problem reading directories in C

I am writing a simple C program that receives a directory as an argument and displays the files in this directory and also his subdirectories. I wrote a "recursive" function for doing that. But for an ...
Dimitri's user avatar
  • 8,280
4 votes
3 answers
8k views

How can I get the last modified time of a directory in Perl on Windows?

In Perl (on Windows) how do I determine the last modified time of a directory? Note: opendir my($dirHandle), "$path"; my $modtime = (stat($dirHandle))[9]; results in the following error: The ...
bob's user avatar
  • 81
1 vote
2 answers
4k views

List regular files only (without directory) problem

Do you know why certain files are not listed by this program, even if they are "regular"?: #include <stdio.h> #include <sys/types.h> #include <sys/param.h> #include <sys/stat.h&...
Denis's user avatar
  • 223