[physfs] open for append & seek & write?

Indy Sams indy at driftsolutions.com
Sun Mar 30 11:38:59 EDT 2008


Hello Vaclav,

      It's the intended behavior yes (ie. Append, always write to the
      end), just like fopen(x, "ab").

Sunday, March 30, 2008, 11:12:04 AM, you wrote:

VV> Hello Indy,
VV> with PHYSFS_openWrite  seek is working, but unfortunately
VV> PHYSFS_openWrite delete file contents at open (like fopen(x, "wb")).
VV> So with PHYSFS_openWrite is in file.txt, after run of program 2 bytes
VV> of NULL (that was seek) and "TEST" string...

VV> PHYSFS_openAppend does not delete file contents, but it ALWAYS write
VV> at the end of the file. Is it a bug or feature?



VV> 2008/3/30, Indy Sams <indy at driftsolutions.com>:
>> Hello Vaclav,
>>
>>       I'd try PHYSFS_openWrite instead of PHYSFS_openAppend. I've
>>       never tried it though, so I don't know if when you start
>>       writing after you seek if it will overwrite what is there, or
>>       add what you wrote and shift everything else down.
>>
>>       Also, I'm not sure if openWrite always forces the opened file
>>       to be empty or not (like fopen(x, "wb")), in which case you'd
>>       have to copy the original file's data into it as well.
>>
>>  Sunday, March 30, 2008, 9:25:03 AM, you wrote:
>>
>>  VV> X-POP-Combiner: Version 1.1/AMD64; host=mail.elit3.com; acct=indy%driftsolutions.com
>>  VV> Return-path: <physfs-return-659-indy=driftsolutions.com at icculus.org>
>>  VV> Envelope-to: indy at driftsolutions.com
>>  VV> Delivery-date: Sun, 30 Mar 2008 08:27:30 -0500
>>  VV> Received: from icculus.org ([67.106.77.212]:52315)
>>  VV>         by dallas3.tx.ipxf.net with esmtps (TLSv1:AES256-SHA:256)
>>  VV>         (Exim 4.68)
>>  VV>         (envelope-from
>>  VV> <physfs-return-659-indy=driftsolutions.com at icculus.org>)
>>  VV>         id 1JfxZ9-0003DX-Rp
>>  VV>         for indy at driftsolutions.com; Sun, 30 Mar 2008 08:27:30 -0500
>>  VV> Received: (qmail 15175 invoked by alias); 30 Mar 2008 09:26:54 -0400
>>  VV> Mailing-List: contact physfs-help at icculus.org; run by ezmlm
>>  VV> Precedence: bulk
>>  VV> X-No-Archive: yes
>>  VV> List-Post: <mailto:physfs at icculus.org>
>>  VV> List-Help: <mailto:physfs-help at icculus.org>
>>  VV> List-Unsubscribe: <mailto:physfs-unsubscribe at icculus.org>
>>  VV> List-Subscribe: <mailto:physfs-subscribe at icculus.org>
>>  VV> Reply-To: physfs at icculus.org
>>  VV> Delivered-To: mailing list physfs at icculus.org
>>  VV> Received: (qmail 13137 invoked by uid 305); 30 Mar 2008 09:26:13 -0400
>>  VV> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
>>  VV>         d=gmail.com; s=beta;
>>  VV>
>>  VV> h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
>>  VV>         bh=KG3GKGZERsQMlJNq99uwZd2kZeYsBHz400SidnJGCME=;
>>  VV>
>>  VV> b=k/WpN/VOBL9ZKYZzBvj83Ijgle42yb1HaC6lDRauPwZirbe4tXCT0Hi4EwVL4iV7HbrdnGIpaInbpA1nX7fTYZN98Lp0SPa/TwDlW3yV6JlbYftN/+iqAlruBoEDvYfcTKt+TjLzyeKef20Ma9B7jV2TRRoVraz6qU5Rt2IjtKg=
>>  VV> DomainKey-Signature: a=rsa-sha1; c=nofws;
>>  VV>         d=gmail.com; s=beta;
>>  VV>
>>  VV> h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
>>  VV>
>>  VV> b=W4P0/evYPbY1Ul6RzVznprSbX8hYdbbZpBkfmWQSzAjJt6Di6LiDyW1HCv1KF1wYN+18eKtCV1aU7iGgH3HQua9+5UYEFIfwr4M7n+qXHL2POUdZd1e3sLdjqvZLeW+O8F1pix3v4ueNZ0Ns4XxHIsMDw9n2JZCITQN/DT+ESlE=
>>  VV> Message-ID:
>>  VV> <b755b4c80803300625q299c981ai440916a3be782fdf at mail.gmail.com>
>>  VV> Date: Sun, 30 Mar 2008 15:25:03 +0200
>>  VV> From: "Vaclav Vanc" <vanc.vaclav at gmail.com>
>>  VV> To: physfs at icculus.org
>>  VV> MIME-Version: 1.0
>>  VV> Content-Type: text/plain; charset=UTF-8
>>  VV> Content-Transfer-Encoding: 7bit
>>  VV> Content-Disposition: inline
>>  VV> Subject: [physfs] open for append & seek & write?
>>  VV> X-Spam-Status: No, score=-102.6
>>  VV> X-Spam-Score: -1025
>>  VV> X-Spam-Bar: ---------------------------------------------------
>>  VV> X-Spam-Flag: NO
>>  VV> X-Text-Classification: spam
>>  VV> X-POPFile-Link: http://127.0.0.1:8080/jump_to_message?view=8846
>>
>>  VV> X-POP-Combiner: Version 1.1/AMD64; host=mail.elit3.com; acct=indy%driftsolutions.com
>>  VV> Return-path: <physfs-return-659-indy=driftsolutions.com at icculus.org>
>>  VV> Envelope-to: indy at driftsolutions.com
>>  VV> Delivery-date: Sun, 30 Mar 2008 08:27:30 -0500
>>  VV> Received: from icculus.org ([67.106.77.212]:52315)
>>  VV>         by dallas3.tx.ipxf.net with esmtps (TLSv1:AES256-SHA:256)
>>  VV>         (Exim 4.68)
>>  VV>         (envelope-from
>>  VV> <physfs-return-659-indy=driftsolutions.com at icculus.org>)
>>  VV>         id 1JfxZ9-0003DX-Rp
>>  VV>         for indy at driftsolutions.com; Sun, 30 Mar 2008 08:27:30 -0500
>>  VV> Received: (qmail 15175 invoked by alias); 30 Mar 2008 09:26:54 -0400
>>  VV> Mailing-List: contact physfs-help at icculus.org; run by ezmlm
>>  VV> Precedence: bulk
>>  VV> X-No-Archive: yes
>>  VV> List-Post: <mailto:physfs at icculus.org>
>>  VV> List-Help: <mailto:physfs-help at icculus.org>
>>  VV> List-Unsubscribe: <mailto:physfs-unsubscribe at icculus.org>
>>  VV> List-Subscribe: <mailto:physfs-subscribe at icculus.org>
>>  VV> Reply-To: physfs at icculus.org
>>  VV> Delivered-To: mailing list physfs at icculus.org
>>  VV> Received: (qmail 13137 invoked by uid 305); 30 Mar 2008 09:26:13 -0400
>>  VV> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
>>  VV>         d=gmail.com; s=beta;
>>  VV>
>>  VV> h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
>>  VV>         bh=KG3GKGZERsQMlJNq99uwZd2kZeYsBHz400SidnJGCME=;
>>  VV>
>>  VV> b=k/WpN/VOBL9ZKYZzBvj83Ijgle42yb1HaC6lDRauPwZirbe4tXCT0Hi4EwVL4iV7HbrdnGIpaInbpA1nX7fTYZN98Lp0SPa/TwDlW3yV6JlbYftN/+iqAlruBoEDvYfcTKt+TjLzyeKef20Ma9B7jV2TRRoVraz6qU5Rt2IjtKg=
>>  VV> DomainKey-Signature: a=rsa-sha1; c=nofws;
>>  VV>         d=gmail.com; s=beta;
>>  VV>
>>  VV> h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition;
>>  VV>
>>  VV> b=W4P0/evYPbY1Ul6RzVznprSbX8hYdbbZpBkfmWQSzAjJt6Di6LiDyW1HCv1KF1wYN+18eKtCV1aU7iGgH3HQua9+5UYEFIfwr4M7n+qXHL2POUdZd1e3sLdjqvZLeW+O8F1pix3v4ueNZ0Ns4XxHIsMDw9n2JZCITQN/DT+ESlE=
>>  VV> Message-ID:
>>  VV> <b755b4c80803300625q299c981ai440916a3be782fdf at mail.gmail.com>
>>  VV> Date: Sun, 30 Mar 2008 15:25:03 +0200
>>  VV> From: "Vaclav Vanc" <vanc.vaclav at gmail.com>
>>  VV> To: physfs at icculus.org
>>  VV> MIME-Version: 1.0
>>  VV> Content-Type: text/plain; charset=UTF-8
>>  VV> Content-Transfer-Encoding: 7bit
>>  VV> Content-Disposition: inline
>>  VV> Subject: [physfs] open for append & seek & write?
>>  VV> X-Spam-Status: No, score=-102.6
>>  VV> X-Spam-Score: -1025
>>  VV> X-Spam-Bar: ---------------------------------------------------
>>  VV> X-Spam-Flag: NO
>>  VV> X-Text-Classification: spam
>>  VV> X-POPFile-Link: http://127.0.0.1:8080/jump_to_message?view=8846
>>
>>
>>
>>  VV> Hi  is it possible, to open existing file, seek in the middle and
>>  VV> write something?
>>  VV> Here is my code...
>>
>>  VV> #include <stdio.h>
>>  VV> #include "physfs.h"
>>
>>  VV> int main(int argc, char *argv[])
>>  VV> {
>>  VV> char string[]="TEST";
>>
>>  VV> PHYSFS_init(argv[0]);
>>  VV> PHYSFS_permitSymbolicLinks( 1 );
>>  VV> PHYSFS_setWriteDir("./");
>>  VV> PHYSFS_addToSearchPath( "./", 0 );
>>
>>  VV> PHYSFS_file *file = PHYSFS_openAppend("file.txt");
>>
>>  VV> PHYSFS_seek(file, 2);
>>  VV> PHYSFS_write(file,  string, 1, 4);
>>
>>  VV> PHYSFS_close(file);
>>  VV> return EXIT_SUCCESS;
>>  VV> }
>>
>>  VV> It should open existing file,  seek to 2th byte from start and write 4
>>  VV> bytes. Unfortunately these 4 bytes are written to the end of the file.
>>  VV> What I am doing wrong?
>>
>>  VV> Thanks.
>>
>>  VV> ---
>>  VV> To unsubscribe, send a blank email to physfs-unsubscribe at icculus.org
>>  VV> Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?4
>>
>>
>>
>>  Best regards,
>>   Indy Sams
>>   mailto:indy at driftsolutions.com
>>
>>   P.S. This is what part of the alphabet would look like if Q & R were eliminated.
>>
>>
>>  ---
>>  To unsubscribe, send a blank email to physfs-unsubscribe at icculus.org
>>  Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?4
>>
>>
>>

VV> ---
VV> To unsubscribe, send a blank email to physfs-unsubscribe at icculus.org
VV> Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?4



Best regards,
 Indy Sams
 mailto:indy at driftsolutions.com

 P.S. This is what part of the alphabet would look like if Q & R were eliminated.




More information about the physfs mailing list