r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Geomol
6-Oct-2010
[18636]
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
Geomol
6-Oct-2010
[18650]
amazing!
ChristianE
6-Oct-2010
[18651]
That was just by luck.
Ladislav
6-Oct-2010
[18652x2]
Hmm, I thought, that OPEN does not create the file when it does not 
exist?
(in R2)
Pekr
6-Oct-2010
[18654]
in R2, you use open/new for such purpose (to create a file if it 
does not exist)
Ladislav
6-Oct-2010
[18655]
But, I need the exact opposite, to open touch a file only if it exists, 
which looks like not supported...
ChristianE
6-Oct-2010
[18656x2]
>> port: open/read %test

** Access Error: Cannot open /c/program files (x86)/rebol/view/test
** Near: port: open/read %test

isn't suited for your purpose, I guess.
Since if it exists, you'll have do do a second OPEN, the file may 
vanish in the meantime.
Ladislav
6-Oct-2010
[18658]
that is a problem, I need to touch the file, i.e. change the date, 
but, nevermind, I can make a work-around
ChristianE
6-Oct-2010
[18659]
*do do = to do
Izkata
6-Oct-2010
[18660]
On recreating touch:  Doesn't writing nothing work?  Seems to here...

write/append %Filename {}
Ladislav
6-Oct-2010
[18661x2]
checking...
hmm, does not do help here...
Izkata
6-Oct-2010
[18663]
Odd... oh well
Gregg
6-Oct-2010
[18664]
I use get/set-modes for my TOUCH, but it was only for local use.
Ladislav
6-Oct-2010
[18665x3]
this looks like working, in R2 as well as in R3, can you confirm?

touch: func [
    {touch the given FILE}
    file [file!]
] [
    file: open file
    clear tail file
    close file
]
The only problem I am having with it is, that it creates the given 
FILE, if it does not exist, while I would prefer the function to 
do nothing in that case
aha, looks like this does not work in 2.7.7 :-(
Sunanda
6-Oct-2010
[18668]
Nothing if file does not exist: add 
   if exists? file [...]
Ladislav
6-Oct-2010
[18669x4]
That works only in single-user
but, nevermind, I found a work-around
so, in 2.7.7 this one does work for me:

touch: func [
    {touch the given FILE}
    file [file!]
] [
    file: open file
    append file ""
    close file
]
So, this one looks "universal":

touch: func [
    {touch the given FILE}
    file [file!]
] [
    file: open file
    append file ""
    clear tail file
    close file
]
Gregg
6-Oct-2010
[18673]
Universal except that is corrupts binary files and will be very slow 
for large files. I don't know if you can be universal, but you can 
get close:

touch: func [
    {touch the given FILE}
    file [file!]
] [
    file: open/seek/binary file
    append file ""
    clear tail file
    close file
]

You just need to remove /binary for R3.
GrahamC
6-Oct-2010
[18674]
call "touch.exe"
Gregg
6-Oct-2010
[18675x2]
Not standard on Windows.
Though with the above you can't specify a given timestamp, which 
is important for general use.
Maxim
6-Oct-2010
[18677]
IIRC there are touch-like functions in the winAPi...
GrahamC
6-Oct-2010
[18678]
I think if you want a particular timestamp you would have to use 
set-modes.
Gregg
6-Oct-2010
[18679x2]
No direct API I know of Max, but I'd rather stay portable as well.
SetFileTime is as close as you get.
Ladislav
7-Oct-2010
[18681x2]
Universal except that is corrupts binary files
 - did you find any corruption?
Though with the above you can't specify a given timestamp
 - that is exactly what is needed
GrahamC
7-Oct-2010
[18683x2]
What's the safest way to check if a string ends in a "/" or not?
all [ not empty? series #'/" = last series ]  seems painful
Sunanda
7-Oct-2010
[18685]
Is this any better? 
     if "/" = back tail series [print true]