File system in linux

D

daniel.maruani

Hi,

how to get the file list of current directory or a directory in C
functions?
and how do I change current dir in C?

Thanks,
Daniel
 
R

Richard.C

#include <unistd.h>

char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);

#include <unistd.h>

char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);
 
F

Flash Gordon

Richard.C wrote:

What are you talking about? I certainly have no idea since I can't see
what you are replying to.

Please leave in some context so that people can see what you are
replying to if you are going to post replies to comp.lang.c. Search
comp.lang.c for the terms Google and context for instructions on how to
do this.
#include <unistd.h>

This header is not part of standard C and is therefor off topic in
comp.lang.c, so if you want to talk about it please keep the discussion
off comp.lang.c
char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);

Perfectly acceptable prototypes for use in a C program. Your point is?
#include <unistd.h>

char *getcwd(char *buf, size_t size);
char *get_current_dir_name(void);
char *getwd(char *buf);

I heard you the first time, no need to repeat yourself.
 
M

marsarden

find current dir :

#include <unistd.h>
char *getcwd(char *buf , size_t size);

change dir :

#include <unistd.h>
int chdir(const char *path);
int fchdir(int fd);

make or remove dir :

#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
int mkdir(const char *pathname,mode_t mode);
int rmdir(const char *pathname);

get dir list :

#include <dirent.h>
#include <sys/types.h>
DIR *opendir(const char *pathname);
struct dirent *readdir(DIR *dir);
int rewindir(DIR *dir);
int closedir(DIR *dir);

notice:each readdir call ,like getchar() in read file , point to the
next sub dir . and to get filename use dirent.d_name[] ,it return the
pointer of file name.
 
F

Flash Gordon

marsarden wrote:

If posting, or cross-porting to comp.lang.c please provide context.
Search comp.lang.c for "google context" for instructions.
find current dir :

#include <unistd.h>

<snip>

All this stuff is system specific. Please do NOT post system specific
questions or answers to comp.lang.c since we only deal with standard,
portable C (POSIX is not the C standard, and not portable to everywhere,
so being POSIX does not count).

I made BOTH of these requests in the post you are replying to, and I
said "please" in both, so you can't be ignoring it because I was
impolite, it can't be because you don't speak English, since your reply
is in English, so it must be because *you* are impolite.

FU set to exclude comp.lang.c
 
S

Sven Hesse

Simply include stdlib.h header and use system("ls");

....Eww, no, _don't_ do that!
 
R

Richard.C

Thank you for your advice!

But, plz notice the TOPIC IS :"File system in linux". NOT " how
tocurrent directory or a directory in C functions".
 
F

Flash Gordon

Richard.C said:
Thank you for your advice!

and thank *you* for ignoring multiple requests to take the *off*
comp.lang.c!
But, plz notice the TOPIC IS :"File system in linux". NOT " how
tocurrent directory or a directory in C functions".

This is COMPLETELY OFF TOPIC in comp.lang.c, so keep it ONLY on the
linux group.
 
Z

Zoran Cutura

Richard.C said:
Thank you for your advice!

But, plz notice the TOPIC IS :"File system in linux". NOT " how
tocurrent directory or a directory in C functions".

That simply makes the question off topic to CLC.

Deleted followup-to mlist.linux.c-programming, cause discussions about
topicality in CLC are off topis there. ;-0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,474
Latest member
VivianStuk

Latest Threads

Top