Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > lseek fails fro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3705 of 3799
Post > Topic >>

lseek fails from dylib, but not app

by eric <eselk@[EMAIL PROTECTED] > Apr 15, 2008 at 01:17 PM

I have some C code that uses open and lseek (and other functions of
course).  I build the C code using XCode as a dylib, I created the
project using the "BSD Dynamic Library" option.  I then created
another project as a "Cocoa Application".

Inside main.m in the app, I can use open and lseek fine.  However,
when the main.m file calls a function inside the dylib that calls open
and lseek, lseek always fails with EINVAL.  I know the file handle is
valid though -- calls to read() work with that same handle, it is only
lseek that fails.

I'm thinking maybe the file is being opened in a way that seeks are
not possible, like in a mode used for pipes or devices that do not
sup****t seeking.  Maybe the default mode for open() is different for a
Cocoa Application project vs a BSD Dylib project?

Any help is greatly appreciated.  Also, what are the most popular Mac
developer forums/lists, and do I need to pay to access them?  I found
public lists on apple.com, but I think most of the real discussion is
on private lists... wherever those are.

I've got my code down to just this in both projects (same code works
in app, but not in dylib):

int fh;
fh = open("/test/test.dat",O_RDWR);
assert(fh != -1);
assert(lseek(fh,0,SEEK_SET) != -1);
close(fh);

The lseek line fails (returns -1), and I've had other code to check
errno, and it is set to EINVAL.  Again, same code works in app, but
fails in dylib.
 




 3 Posts in Topic:
lseek fails from dylib, but not app
eric <eselk@[EMAIL PRO  2008-04-15 13:17:08 
Re: lseek fails from dylib, but not app
eric <eselk@[EMAIL PRO  2008-04-15 14:20:29 
Re: lseek fails from dylib, but not app
Robert Spykerman <robe  2008-04-29 19:10:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 5:52:04 CDT 2008.