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

Open
rebolbot opened this issue Jan 18, 2009 · 4 comments
Open

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

rebolbot opened this issue Jan 18, 2009 · 4 comments

Comments

@rebolbot
Copy link
Collaborator

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

CC – Data [ Version: alpha 31 Type: Bug Platform: All Category: n/a Reproduce: Always Fixed-in:alpha 55 ]

@rebolbot
Copy link
Collaborator Author

Submitted by: BrianH

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

@rebolbot
Copy link
Collaborator Author

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
Copy link
Collaborator Author

rebolbot commented 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
Copy link
Collaborator Author

rebolbot commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant