Does anyone know a way to read the filenames from a given directory in
C in a Solaris environment?
I did this, but it seems goofy:
sprintf(t, "ls *.csv > filenames.txt");
system(t);
fptr = fopen("filenames.txt", "r");
while (!(feof(fptr)))
{
fgets(line, 100, fptr);
blah-blah-blah
Is there a way to do this without creating another file?
-Tim 8 3676
Tim wrote: Does anyone know a way to read the filenames from a given directory in C in a Solaris environment?
I did this, but it seems goofy:
sprintf(t, "ls *.csv > filenames.txt"); system(t); fptr = fopen("filenames.txt", "r"); while (!(feof(fptr))) { fgets(line, 100, fptr); blah-blah-blah
Is there a way to do this without creating another file?
Not in Standard C, which does not assume a file system
that has a notion of "directory."
<off-topic>"man readdir", and take any further questions
to comp.unix.programmer.</off-topic>
-- Er*********@sun.com
In article <e9**************************@posting.google.com >, ya*****@hotmail.com says... Does anyone know a way to read the filenames from a given directory in C in a Solaris environment?
You would be better off asking in one of the Solaris development
groups. This group is about standard C only.
I did this, but it seems goofy:
Yes. I can pretty much guarantee there are better ways to do
it than that on your target platform.
--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: po********@sco.com
"Tim" <ya*****@hotmail.com> wrote: e9**************************@posting.google.com... Does anyone know a way to read the filenames from a given directory in C in a Solaris environment?
I did this, but it seems goofy: ...
You can try POSIX functions opendir(), readdir() and closedir():
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
int main(void)
{
DIR* pdir = opendir("/");
struct dirent* pent;
if(pdir)
{
while(pent = readdir(pdir))
{
printf("entry: %s\n", pent->d_name);
}
closedir(pdir);
}
return 0;
}
See the manual page for more information.
Best Regards,
Julian
As far as C is concerned, how "portable" is POSIX? Would I run into
any trouble if I needed to compile this code in a couple of different
UNIX environments?
<I wasn't sure if this question was better suited to the UNIX
group...>
-Tim
Jack Klein <ja*******@spamcop.net> wrote in message news:<2s********************************@4ax.com>. .. On Wed, 17 Dec 2003 10:23:49 +0800, "Julian Zhang" <ju******@263.sina.com> wrote in comp.lang.c:
"Tim" <ya*****@hotmail.com> wrote: e9**************************@posting.google.com... Does anyone know a way to read the filenames from a given directory in C in a Solaris environment?
I did this, but it seems goofy: ...
You can try POSIX functions opendir(), readdir() and closedir():
Please don't vandalize comp.lang.c with off-topic answers. POSIX is not topical here. It is in news:comp.unix.programmer and many other groups.
Ignore my question about "portability," after I turned my brain on and
did a quick search over at webopedia.com I realized that POSIX is
designed to make code portable.
Thanks for all the help!
-Tim
Jack Klein <ja*******@spamcop.net> wrote in message news:<2s********************************@4ax.com>. .. On Wed, 17 Dec 2003 10:23:49 +0800, "Julian Zhang" <ju******@263.sina.com> wrote in comp.lang.c:
"Tim" <ya*****@hotmail.com> wrote: e9**************************@posting.google.com... Does anyone know a way to read the filenames from a given directory in C in a Solaris environment?
I did this, but it seems goofy: ...
You can try POSIX functions opendir(), readdir() and closedir():
Please don't vandalize comp.lang.c with off-topic answers. POSIX is not topical here. It is in news:comp.unix.programmer and many other groups.
Tim writes: Ignore my question about "portability," after I turned my brain on and did a quick search over at webopedia.com I realized that POSIX is designed to make code portable.
Thanks for all the help! -Tim
Jack Klein <ja*******@spamcop.net> wrote in message
news:<2s********************************@4ax.com>. .. On Wed, 17 Dec 2003 10:23:49 +0800, "Julian Zhang" <ju******@263.sina.com> wrote in comp.lang.c:
"Tim" <ya*****@hotmail.com> wrote: e9**************************@posting.google.com... > Does anyone know a way to read the filenames from a given directory
in > C in a Solaris environment? > > I did this, but it seems goofy: > ...
You can try POSIX functions opendir(), readdir() and closedir():
Please don't vandalize comp.lang.c with off-topic answers. POSIX is not topical here. It is in news:comp.unix.programmer and many other groups.
If you look real close at the thread, you will see that Jack Klein, who you
thank, actually chastised someone else for trying to help you. You are a
true gentleman. Or something.
"osmium" <r1********@comcast.net> writes:
[...] If you look real close at the thread, you will see that Jack Klein, who you thank, actually chastised someone else for trying to help you. You are a true gentleman. Or something.
As we've discussed at length here, redirecting off-topic questions to
a more appropriate newsgroup is actually more helpful than trying to
answer them here. If I want to post something about POSIX, I'd much
rather post it over in comp.unix.programmer, where they know enough
about it to correct my inevitable errors.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DaRemedy |
last post by:
Hiya,
If I had several folders full of images, how can I get PHP to open the
folder, read the image names and save the image names (inc extension) to a
MySQL database?
What I am trying to do...
|
by: rbutch |
last post by:
guys, i need a little help with this.
this is working (well sort of)
i get the info, but it's not moving to a new line as it iterates thru the array
and all of the fields are like ONE HUGE LONG...
|
by: Joey Martin |
last post by:
Can someone help me with a quick script.
I need to browse filenames in a directory and insert them into my sql
table. I want to run this in an ASP page. I know how to connect to the
database,...
|
by: DOM_scripter |
last post by:
Hi, I want to make an automatic foto album that lets me only drop a
bunch of pictures in a folder. When I open the browser a javascript
should read all the filenames in the folder, show thumbnails...
|
by: Jan Eliasen |
last post by:
Hi
I am receiving some XML form a component that I can not change. This
component reads emails from a POP3 Server and takes the body and
attachments and write them in an XML format for me.
...
|
by: aruna sahu |
last post by:
Hi,
I want to know ,how to read only filenames from a folder in perl?
please answer me with an example.
|
by: waynetheengineer |
last post by:
Hello everyone :)
I am trying to write VB code for reading filenames and file property values in a specific directory.
For example, I have a directory called C:/Bears and in that directory...
|
by: Joakim Hove |
last post by:
Hello,
I am reading a filename from the user - the loop is typically like
this:
1. Read a directory from the user.
2. Read several filenames from the user.
The filenames read in 2. above...
|
by: Manogna |
last post by:
hi! all,
in a directory nearly 10 zipped file are available.
totally the size of the all files is nearly 15GB.
i have to retrive the line which dont have the text "ORA" from each file...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |