Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRITE does not update file size (EOF position) #552

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 1 comment
Closed

WRITE does not update file size (EOF position) #552

Siskin-Bot opened this issue Feb 15, 2020 · 1 comment
Assignees
Labels
CC.resolved Issue with CureCode status built, tested or complete Datatype: file! Datatype: port! Oldes.resolved Bugs/wishes with Oldes' fixes/features Status.important Test.written Type.bug

Comments

@Siskin-Bot
Copy link
Collaborator

Siskin-Bot commented Feb 15, 2020

Submitted by: Steeve

If you open a file port and then change the data in the file, READ will only see changes to the data that are before what the end of file position was when the port was opened. Any data that is added on after the end of file, READ won't see. The end-of-file position that is used by READ is not getting updated on WRITE.

It doesn't matter if the port is opened in /seek mode or not, nor does it matter whether you use READ and WRITE or INSERT, APPEND and COPY. If you read data from the same file with a different port, whether or not the original port is still open, the new data is there.

>> write %file to-binary "Hello World!"
>> f: open/seek %file
>> to-string read/seek f 0
== "Hello World!"
>> write/seek f to-binary "a" 4  ; In range
>> write/seek f to-binary " Goodbye World!" 12  ; Out of range
>> to-string read/seek f 0
== "Hella World!"  ; Original length - note the first change
>> to-string read/seek %file 0
== "Hella World! Goodbye World!"  ; Correct data

Imported from: CureCode [ Version: alpha 31 Type: Bug Platform: All Category: n/a Reproduce: Always Fixed-in:alpha 55 ]
Imported from: metaeducation#552

Comments:

Rebolbot commented on Jan 18, 2009:

Submitted by: BrianH

This bug is confirmed by my testing. It seems like a simple fix.


Rebolbot commented on Jan 19, 2009:

Submitted by: Steeve

you can notice that even doing a query on the port after the append

>> query f

we don't have the new length.


Rebolbot commented on Jul 8, 2009:

Submitted by: RobertS

; r3-a68
write %user.r my-modified-settings-as-binary
; console gets odd code dump but expected is likely an unset! 
; dump starts make port! so looks like the action! src ...

Rebolbot commented on Jul 8, 2009:

Submitted by: BrianH

WRITE in R3 returns the port you are writing to, in case you want to write something else to it.

Or in the case of HTTP posts, WRITE returns the return data.


Rebolbot mentioned this issue on Jan 12, 2016:
clear on port leaves length? unchanged


Rebolbot added Type.bug and Status.important on Jan 12, 2016


@Siskin-Bot Siskin-Bot added the CC.resolved Issue with CureCode status built, tested or complete label May 22, 2020
@Oldes Oldes closed this as completed Feb 17, 2021
Oldes added a commit to Oldes/Rebol3 that referenced this issue Feb 19, 2021
@Oldes
Copy link
Owner

Oldes commented Apr 6, 2021

It seems to be working only on Windows!

@Oldes Oldes reopened this Apr 6, 2021
@Oldes Oldes self-assigned this Sep 28, 2021
@Oldes Oldes added the Oldes.resolved Bugs/wishes with Oldes' fixes/features label Oct 3, 2021
Oldes added a commit to Oldes/Rebol3 that referenced this issue Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CC.resolved Issue with CureCode status built, tested or complete Datatype: file! Datatype: port! Oldes.resolved Bugs/wishes with Oldes' fixes/features Status.important Test.written Type.bug
Projects
None yet
Development

No branches or pull requests

2 participants