Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copying files om Mac OS... please Help! XCode!

4 views
Skip to first unread message

Fonarix

unread,
Sep 20, 2006, 9:36:50 AM9/20/06
to

I'm trying to copy file on the same volume,
File is a shared library; in the source directory it's size 16 Kbytes.
After copying it's size 6 KB, and it has type Excel file!!! ))) And
it's doesn't work!


Procedure:

OSStatus DoStupidCopy(char *pszSrcPath, char *pszDestDir)
{
static const int iBufSize= 4*4096;
char pBuf[iBufSize];

FILE* fSource = fopen(pszSrcPath,"rb");
if (!fSource)
return 1;//throw "Can't open file";
FILE* fTarget = fopen(pszDestDir,"wb");
if (!fTarget)
return 1;//throw "Can't write file";
int len;
while ( len = fread( pBuf, sizeof(char), iBufSize, fSource ) )
{
fwrite(pBuf, sizeof(char), len, fTarget);
}
fclose(fSource);
fclose(fTarget);
return noErr;
}


I've spent a lot of time to learn how to use MoreFilesX but I can't do
anything with it.

Beforehand thanks.

David Phillip Oster

unread,
Sep 20, 2006, 9:44:01 AM9/20/06
to
In article <1158759410.7...@m7g2000cwm.googlegroups.com>,
"Fonarix" <fon...@ukr.net> wrote:


From the man page for fread:
---------------
The functions fread() and fwrite() advance the file position indicator
for the stream by the number of bytes read or written. They return the
number of objects read or written. If an error occurs, or the end-offile
is reached, the return value is a short object count (or zero).

The function fread() does not distinguish between end-of-file and error,
and callers must use feof(3) and ferror(3) to determine which occurred.
The function fwrite() returns a value less than nmemb only if a write
error has occurred.
---------------

Please rewrite your example to properly check the return values of fread
and fwrite, and if you still have a problem, ask again.

Also, don't forget Bundles (folders that the Finder presents as a
single, file-like object. For example, .framework files), and resource
forks.

Beavis

unread,
Sep 20, 2006, 9:44:53 AM9/20/06
to

Fonarix написав:

> I'm trying to copy file on the same volume,
> File is a shared library; in the source directory it's size 16 Kbytes.
> After copying it's size 6 KB, and it has type Excel file!!! ))) And
> it's doesn't work!


He-he-dude)
RRRRRRRRRRRRRRRR!!!!!!!!!!!!!!!!

Fonarix

unread,
Sep 20, 2006, 9:52:09 AM9/20/06
to
> From the man page for fread:
> ---------------
> The functions fread() and fwrite() advance the file position indicator
> for the stream by the number of bytes read or written. They return the
> number of objects read or written. If an error occurs, or the end-offile
> is reached, the return value is a short object count (or zero).
>
> The function fread() does not distinguish between end-of-file and error,
> and callers must use feof(3) and ferror(3) to determine which occurred.
> The function fwrite() returns a value less than nmemb only if a write
> error has occurred.
> ---------------
>
> Please rewrite your example to properly check the return values of fread
> and fwrite, and if you still have a problem, ask again.
>
> Also, don't forget Bundles (folders that the Finder presents as a
> single, file-like object. For example, .framework files), and resource
> forks.


In this case how can I copy bundle? (Shared library made on codewarrior
compiler).
This file in Midnight commander is present as one file, and it's size
6 KB but in finder 16! After copying in MC it's size still 6 KB and
in finder too!

Beavis

unread,
Sep 20, 2006, 10:13:52 AM9/20/06
to

David Phillip Oster написав:
Arre you oYster??????Fuck !!!!I've sme problem!
FUCK!

Beavis

unread,
Sep 20, 2006, 10:40:39 AM9/20/06
to

Beavis написав:

> David Phillip Oster написав:
> Arre you oYster??????Fuck !!!!I've sme problem!
> FUCK!

Sorry!
I'll kill myself by the wall!

Fonarix

unread,
Sep 20, 2006, 10:51:48 AM9/20/06
to
> From the man page for fread:
> ---------------
> The functions fread() and fwrite() advance the file position indicator
> for the stream by the number of bytes read or written. They return the
> number of objects read or written. If an error occurs, or the end-offile
> is reached, the return value is a short object count (or zero).
>
> The function fread() does not distinguish between end-of-file and error,
> and callers must use feof(3) and ferror(3) to determine which occurred.
> The function fwrite() returns a value less than nmemb only if a write
> error has occurred.
> ---------------
>
> Please rewrite your example to properly check the return values of fread
> and fwrite, and if you still have a problem, ask again.
>
> Also, don't forget Bundles (folders that the Finder presents as a
> single, file-like object. For example, .framework files), and resource
> forks.


This code works well in debugger... Source file size 6190 destination
file size 6190, in finder 16 KB! Have Mac OS some function which I can
use And copy it successful???
Also I tried to use: status = ::PBHCopyFileSync(&paramBlock) ;
But I got status is -50 for local volume.
Thanks.

Fonarix

unread,
Sep 21, 2006, 2:42:27 AM9/21/06
to
I've found this:

Incidentally, FSCopyObject does not work correctly on 10.4 -- it does
not copy
HSF+ Extended Attributes -- so the correct solution here is to call
FSCopyObjectSync from the OS on 10.4 and later, and only use the
FSCopyObject
sample code on 10.3.


Thanks!!!

Beavis

unread,
Sep 21, 2006, 2:52:39 AM9/21/06
to

Fonarix написав:

FUCK!

Beavis

unread,
Sep 25, 2006, 3:53:00 AM9/25/06
to

Beavis написав:

>
> FUCK!

So...nobody here...i feel so alone ...where ary yo, fishhead?Are you
dead?
Who am i?
Where is butthead?
So many questions...so few answers...so fuckingly few drugs...fuck...
mac!os!x!
aaaaa!
mac's!!!
it's so big!!!
Fuckin' cheese!!!
No more mushrooms!!!
sick my duck!
Chao!

0 new messages