[PHP] File Random Access

2002-10-30 Thread Rick Emery
I never noticed before...there is no easy way to perform random-access read and WRITE 
on a
file.

I vote/recommend/suggest that this most basic functionality be added to the next 
release
of PHP.  This would not be an enhancement; rather, it is correcting a serious flaw.

Or am I missing something

- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Wednesday, October 30, 2002 6:28 AM
Subject: Re: [PHP] write on the begin of a file


There is no insert in fputs, you need to make a new file and then rename
it to
your old one, or build it in the memory and then overwrite it.

Sbastien Eckert -- Netika wrote:




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] File Random Access

2002-10-30 Thread Ford, Mike [LSS]
 -Original Message-
 From: Rick Emery [mailto:[EMAIL PROTECTED]]
 Sent: 30 October 2002 13:46

 I never noticed before...there is no easy way to perform
 random-access read and WRITE on a
 file.

 I vote/recommend/suggest that this most basic functionality
 be added to the next release
 of PHP.  This would not be an enhancement; rather, it is
 correcting a serious flaw.

 Or am I missing something

I haven't tested this, so I may be missing something, but doesn't
fopen('filename', 'rb+') or fopen('filename', 'ab+') allow for this?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] File Random Access

2002-10-30 Thread Cal Evans
Rick,

If you have a file that is to large to simply read into memory, do your
inserts and then write back out then you need to move it to a database.
Cluttering up the main code base with random flat-file reads and writes is
not necessary.

If you seriously need it then you can do as suggested, create a new file,
read from the old file, insert at the proper place, close, delete, rename,
rinse, repeat. If you think about it, that's what the php developers will
have to do to accommodate your request. (assuming again that your file is
too large to simply fit in memory.)

It may be a need for you but in my 2 years of using PHP, you are the first
person I've seen ask for it.  Therefore I don't think it qualifies as a
serious flaw.

IMHO, etc.
=C=
*
* Cal Evans
* The Virtual CIO
* http://www.calevans.com
*


-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 30, 2002 7:46 AM
To: PHP
Subject: [PHP] File Random Access


I never noticed before...there is no easy way to perform random-access read
and WRITE on a
file.

I vote/recommend/suggest that this most basic functionality be added to the
next release
of PHP.  This would not be an enhancement; rather, it is correcting a
serious flaw.

Or am I missing something

- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Wednesday, October 30, 2002 6:28 AM
Subject: Re: [PHP] write on the begin of a file


There is no insert in fputs, you need to make a new file and then rename
it to
your old one, or build it in the memory and then overwrite it.

Sbastien Eckert -- Netika wrote:




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] File Random Access

2002-10-30 Thread Rick Emery
You are correct.  In fact, simply r+ works; I just tried it.
Thanks
- Original Message - 
From: Ford, Mike [LSS] [EMAIL PROTECTED]
To: 'Rick Emery' [EMAIL PROTECTED]; PHP [EMAIL PROTECTED]
Sent: Wednesday, October 30, 2002 8:05 AM
Subject: RE: [PHP] File Random Access


 -Original Message-
 From: Rick Emery [mailto:[EMAIL PROTECTED]]
 Sent: 30 October 2002 13:46

 I never noticed before...there is no easy way to perform
 random-access read and WRITE on a
 file.

 I vote/recommend/suggest that this most basic functionality
 be added to the next release
 of PHP.  This would not be an enhancement; rather, it is
 correcting a serious flaw.

 Or am I missing something

I haven't tested this, so I may be missing something, but doesn't
fopen('filename', 'rb+') or fopen('filename', 'ab+') allow for this?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] File Random Access

2002-10-30 Thread Ford, Mike [LSS]
 -Original Message-
 From: Rick Emery [mailto:[EMAIL PROTECTED]]
 Sent: 30 October 2002 14:35
 
 You are correct.  In fact, simply r+ works; I just tried it.
 Thanks

Yes, but that's not guaranteed to be binary-safe on Windows -- if your data happens to 
include null bytes, you might get unexpected file truncations (I think...)!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php