problem getting qnx4 file sizes in C

Hello,

I’m having a difficult time getting the current file size of a qnx4 file
in C. I tried using stat and lstat from the qnx watcom C library book,
but both just error out. Does anyone have any suggestions?

Thanks!

Karen


-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu | fingers to count in binary, but should
http://www.chibiusa.com | avoid the numbers 4, 128 & 132 in public.

Maybe this?

long int length = filelength(fd);

“Karen E. Stevens” wrote:

Hello,

I’m having a difficult time getting the current file size of a qnx4 file
in C. I tried using stat and lstat from the qnx watcom C library book,
but both just error out. Does anyone have any suggestions?

Thanks!

Karen


-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu > | fingers to count in binary, but should
http://www.chibiusa.com > | avoid the numbers 4, 128 & 132 in public.

Thanks! Somehow I missed the obvious function =)

Karen noted that Dean Douthat <ddouthat@faac.com> wrote:
: Maybe this?

: long int length = filelength(fd);

: “Karen E. Stevens” wrote:

: > Hello,
: >
: > I’m having a difficult time getting the current file size of a qnx4 file
: > in C. I tried using stat and lstat from the qnx watcom C library book,
: > but both just error out. Does anyone have any suggestions?
: >
: > Thanks!
: >
: > Karen
: >
: > –
: > -.-- — …- / – …- … - / -… . / -… — .-. . -…
: > Karen Stevens | A computer science major may use their
: > kstevens@mtu.edu | fingers to count in binary, but should
: > http://www.chibiusa.com | avoid the numbers 4, 128 & 132 in public.

\

-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu | fingers to count in binary, but should
http://www.chibiusa.com | avoid the numbers 4, 128 & 132 in public.

Its probably better to figure out why its failing than using something else,
you may get the same error with a different call. Try using perror() to see
why it failed and go from there.

Jon

Karen E. Stevens <kstevens@mtu.edu> wrote in message
news:8lk4fp$blc$1@campus3.mtu.edu

Hello,

I’m having a difficult time getting the current file size of a qnx4 file
in C. I tried using stat and lstat from the qnx watcom C library book,
but both just error out. Does anyone have any suggestions?

Thanks!

Karen


-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu > | fingers to count in binary, but should
http://www.chibiusa.com > | avoid the numbers 4, 128 & 132 in public.

Actually, it was more of a data format error, stat had too much
information anyway, and all I need is the current file size.
‘filesize’ works perfectly =)

Thanks again,

Karen


Karen noted that Jonathan Richardson <jrichard@nospam.ise.bc.ca> wrote:
: Its probably better to figure out why its failing than using something else,
: you may get the same error with a different call. Try using perror() to see
: why it failed and go from there.

: Jon

: Karen E. Stevens <kstevens@mtu.edu> wrote in message
: news:8lk4fp$blc$1@campus3.mtu.edu
: > Hello,
: >
: > I’m having a difficult time getting the current file size of a qnx4 file
: > in C. I tried using stat and lstat from the qnx watcom C library book,
: > but both just error out. Does anyone have any suggestions?
: >
: > Thanks!
: >
: > Karen
: >
: > –
: > -.-- — …- / – …- … - / -… . / -… — .-. . -…
: > Karen Stevens | A computer science major may use their
: > kstevens@mtu.edu | fingers to count in binary, but should
: > http://www.chibiusa.com | avoid the numbers 4, 128 & 132 in public.


\

-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu | fingers to count in binary, but should
http://www.chibiusa.com | avoid the numbers 4, 128 & 132 in public.

Previously, Karen E. Stevens wrote in comp.os.qnx:

Actually, it was more of a data format error, stat had too much
information anyway, and all I need is the current file size.
‘filesize’ works perfectly =)

What’s filesize(), and are you using QNX4 or Nto? Stat is the way to go,
and any function you use will be calling stat eventually. Try this,
printing st_size instead of the times.

---- ftime.c –
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>

char USAGE[] =
“usage: devinfo [device [device]…]”
;
void Usage(FILE* file)
{
fprintf(file, “%s\n”, USAGE);
}

void main(int argc, char* argv[])
{
int index = 1;


if(argc < 2)
{
Usage(stderr);
exit(0);
}

while(argv[index])
{
const char* device = argv[index++];
struct stat s;

if(stat(device, &s) == -1) {
fprintf(stderr, “stat ‘%s’ failed: [%d] %s\n”, device, errno, strerror(errno));
exit(1);
}

printf(“ftime %d mtime %d atime %d ctime %d name ‘%s’\n”,
s.st_ftime,
s.st_mtime,
s.st_atime,
s.st_ctime,
device
);
}
exit(0);
}

Thanks again,

Karen


Karen noted that Jonathan Richardson <> jrichard@nospam.ise.bc.ca> > wrote:
: Its probably better to figure out why its failing than using something else,
: you may get the same error with a different call. Try using perror() to see
: why it failed and go from there.

: Jon

: Karen E. Stevens <> kstevens@mtu.edu> > wrote in message
: news:8lk4fp$blc$> 1@campus3.mtu.edu> …
: > Hello,
:
: > I’m having a difficult time getting the current file size of a qnx4 file
: > in C. I tried using stat and lstat from the qnx watcom C library book,
: > but both just error out. Does anyone have any suggestions?
:
: > Thanks!
:
: > Karen
:
: > –
: > -.-- — …- / – …- … - / -… . / -… — .-. . -…
: > Karen Stevens | A computer science major may use their
: > > kstevens@mtu.edu > | fingers to count in binary, but should
: > > http://www.chibiusa.com > | avoid the numbers 4, 128 & 132 in public.


\

-.-- — …- / – …- … - / -… . / -… — .-. . -…
Karen Stevens | A computer science major may use their
kstevens@mtu.edu > | fingers to count in binary, but should
http://www.chibiusa.com > | avoid the numbers 4, 128 & 132 in public.


Sam Roberts (sam@cogent.ca), Cogent Real-Time Systems (www.cogent.ca)
“News is very popular among its readers.” - RFC 977 (NNTP)