World: r3wp
[Core] Discuss core issues
older newer | first last |
Ladislav 6-Oct-2010 [18600] | I am wondering what is the simplest method to implement the Touch function in REBOL? Is there anything simpler than to append one character to the file and remove it again? |
Geomol 6-Oct-2010 [18601x3] | The UNIX touch create the file, if it doesn't exists. (If you will make sure, that happens.) |
Maybe look at a source of "touch" to see, what it does? | |
and how it does it. | |
Ladislav 6-Oct-2010 [18604] | seems, that it does it differently, but, actually, that method is not suitable for my purposes, I need an "across network" touch, which should be consistent with "storage clock" |
Graham 6-Oct-2010 [18605x2] | why not just alter the time of the file .. .and if it doesn't exist, then create the file? |
I think I did that for my directory syncing tool | |
Ladislav 6-Oct-2010 [18607x2] | That is actually not what I want - suppose that you manipulate a file on a different machine, not using synchronized clock |
BTW, did you use the SET-MODES function? | |
Graham 6-Oct-2010 [18609x2] | Yes. |
I would have thought that logically the file on the other pc is for the time owned by the original pc | |
Ladislav 6-Oct-2010 [18611] | Does the SET-MODES function work for you in R2.7.7? |
Graham 6-Oct-2010 [18612x2] | Haven't tried ... not for many years |
There's no way PC1 can know what time it is on PC2 | |
Ladislav 6-Oct-2010 [18614x2] | There is: Touch a file and get its time |
;-) | |
Graham 6-Oct-2010 [18616] | that implies the resource on pc2 has a touch facility |
Ladislav 6-Oct-2010 [18617] | Actually, that is why I am using the Touch function |
Graham 6-Oct-2010 [18618] | no watch?? |
Ladislav 6-Oct-2010 [18619x3] | right |
(I just do not know on which machine the file is) | |
a related problem: how to remove the last character from a file in R3? | |
Graham 6-Oct-2010 [18622x2] | In my file replication tool I hit a snag ... when replicating directories I was not able to set the file date :( |
ie. get-modes can't set directory dates | |
Ladislav 6-Oct-2010 [18624] | I suppose you mean Set-modes? |
Graham 6-Oct-2010 [18625x2] | yes |
Now that I think about it .. my NAS box has that problem .. I copy files to it, and the file dates are in the future because the box's time runs fast :( | |
Geomol 6-Oct-2010 [18627] | how to remove the last character from a file in R3? I don't know, if it will be done differently in R3, but using R2 I would do something like: sz: length? p: open/binary %file write/binary %newfile copy/part p sz - 1 close p |
Ladislav 6-Oct-2010 [18628x2] | hmm, ugly |
in R2 it can be simpler, but probably not in R3 | |
Geomol 6-Oct-2010 [18630x2] | yeah! :-) |
Is this better with your definition of 'ugly'? write/binary %file copy/part read/binary %file (get in info? %file 'size) - 1 | |
Ladislav 6-Oct-2010 [18632] | - that is the same for me, I would like to just remove one character, not to copy the whole file |
Geomol 6-Oct-2010 [18633] | Is that possible? |
Ladislav 6-Oct-2010 [18634] | in R2 it is, as it looks |
Geomol 6-Oct-2010 [18635x2] | I mean, is it possible in R2? |
Could you show me? | |
Ladislav 6-Oct-2010 [18637] | port: open %file remove back tail file close port |
Geomol 6-Oct-2010 [18638] | Neat! :) |
Ladislav 6-Oct-2010 [18639] | remove back tail port is what I meant |
Geomol 6-Oct-2010 [18640x2] | yes |
And it doesn't work in R3 for some reason? | |
Ladislav 6-Oct-2010 [18642x2] | ...at least not for me... |
:-( | |
Geomol 6-Oct-2010 [18644x3] | Here (under windows) a unix format text file is changed to dos format, if I do, what you just suggested. So it become longer. |
Doing open/binary and it works. | |
Using R3, I get: ** Script error: cannot use remove on port! value Probably the same, you see. | |
ChristianE 6-Oct-2010 [18647] | Using R3, >> clear back tail port works for me. |
Ladislav 6-Oct-2010 [18648x2] | aha, fine |
thanks | |
older newer | first last |