Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > About checking executable files

Reply
Thread Tools

About checking executable files

 
 
mhk
Guest
Posts: n/a
 
      11-04-2003
Hi ,

i am writing a c language program in Unix to see the executable files in
a directory and it works if the directory is current but if i change to
another directory than current directory then it show all the files even
if not executable.

here is the main code

while (p = readdir(dp))
{
stat(p->d_name, &s);

if (strcmp( p->d_name,".")!= 0 && strcmp( p->d_name,"..")!= 0 )
{
if (s.st_mode & S_IXUSR)
{
cc = ctime(&s.st_mtime);
printf("%s| %s \n", p->d_name, cc);
}
}
}

can anyone help?

Thanks alot.

Jeff

 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      11-04-2003
mhk wrote:
>
> Hi ,
>
> i am writing a c language program in Unix


> while (p = readdir(dp))


Try
news:comp.unix.programmer

readdir isn't a standard C library function.

--
pete
 
Reply With Quote
 
 
 
 
Derk Gwen
Guest
Posts: n/a
 
      11-05-2003
mhk <(E-Mail Removed)> wrote:
# Hi ,
#
# i am writing a c language program in Unix to see the executable files in
# a directory and it works if the directory is current but if i change to
# another directory than current directory then it show all the files even
# if not executable.
#
# here is the main code
#
# while (p = readdir(dp))

Returns the path relative to the directory being read. Unless that
is the current directory, you're looking for files in the wrong
directory. You have to prefix the directory path to d_name.

# stat(p->d_name, &s);

If you checked the return value and errno of stat, it would be telling
you you've got nonexistent files.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
Why are we here?
whrp
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create executable from executable with py2exe vedrandekovic@gmail.com Python 0 03-29-2008 12:23 PM
Running an Executable Before Executable JAR Jason Cavett Java 8 05-16-2007 07:14 PM
what is fast dynamically linked executable or statically linked executable ?how to decide? pratap C Programming 20 03-07-2007 04:46 AM
How can I run a c executable in pwd ,while the executable is in some other directory vishsid3@gmail.com C Programming 15 08-21-2006 06:04 AM
Can I make .class files run like executable .jar files on a Windows platform? phillipedison1891@yahoo.com Java 3 03-09-2005 10:44 PM



Advertisments