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

World: r3wp

[Core] Discuss core issues

Gregg
5-Jul-2007
[8373]
I thought I had a list somewhere, but can't find it. You probably 
already have all these.

files:
	file-modes
	copy-modes
net ports:
	network-modes
	interfaces
ports:
	port-modes
btiffin
5-Jul-2007
[8374]
Ladislav;  Thank you sir.
Sunanda
5-Jul-2007
[8375]
Thanks Gregg -- I was looking for the definite list of file modes: 
world-write etc.
A bit of extra Googling got me to here:
http://www.rebol.com/docs/core25.html#sect1.1.

It would have been easier with some SEO on the .com and .net sites.
Izkata
5-Jul-2007
[8376]
Like this?
>> print mold get-modes %Fonts.r 'file-modes

[status-change-date modification-date access-date owner-name group-name 
owner-id group-id owner-read owner-write owner-execute group-read 
group-write group-execute world-read world-write world-execute set-user-id 
set-group-id full-path]
>> print mold get-modes %Fonts.r 'world-write
false
Sunanda
6-Jul-2007
[8377]
Thanks Izkata.

The difficulty there is that it returns only the modes availlable 
on your platform.
I needed all the possible modes for cross-platform coding/
Pekr
7-Jul-2007
[8378]
guys, do you have recursive directory read function? Simply put - 
what I need for our kiosk is:

 - script running in the background, window-less
- script checks for new drive to appear periodically
- then it reads specific directory, e.g. %/e/kiosk-update

- then it reads files, and stores them to target dir, not carring 
about adding new dir/file, simply overwriting it

It is kind of one-sided sync :-)

I can't find anything usefull on rebol.org ....
Sunanda
7-Jul-2007
[8379]
Here's some code that traverses an entire dircetory tree:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlTQBC
ICarii
7-Jul-2007
[8380x4]
what in the following code would cause cannot insert on port error?
updatedir: func [current-dir basedir /local contents base-contents 
item base-item item-info base-item-info][

 unless exists? current-dir [return] ;returns if source is not present 
 - eg someone removes a cd
	contents: read current-dir

 unless exists? basedir [make-dir basedir while [not exists? basedir][wait 
 0]]
	base-contents: read basedir
	foreach item contents [
		base-item: find base-contents item
		either dir? item [
			updatedir join current-dir item join basedir item
		][
			either none? base-item [

    write/binary join basedir item read/binary join current-dir item
			][
				item-info: info? join current-dir item
				base-item-info: info? join basedir base-item
				if item-info/date > base-item-info/date [

     write/binary join basedir item read/binary join current-dir item
				]
			]
		]
	]
]
updatedir %sourcedir/ %destdir/
when run repeatedly (if i trap the error) it completes successfully.. 
is there a 1 write at a time rule in rebol?
but apart from the error - is that the sort of thing you were looking 
for Petr?
Pekr
7-Jul-2007
[8384x3]
Icarii - yes, that might help ....
oh my, how usefull is read %/, if you can't use it further dynamically?

== [%c/ %d/ %e/ %g/]


it is missing one backslash. You simply can't  do thing like foreach 
drive drives [print exists? join drive "kiosk/"]
it has to be a bug, because it is not logical - it is a result of 
'read operation, yet if you query the result, e.g. exists? %c/ you 
get 'false result. That is not imo correct.
ICarii
7-Jul-2007
[8387]
that only probably happens under windows where the filesystem is 
so screwy
Pekr
7-Jul-2007
[8388]
:-)
Gabriele
7-Jul-2007
[8389x6]
petr, no, that is not a bug.
>> read %public/www.rebol.com/
== [%index.r %docs/ %bay.jpg %view/ %downloads/]
do you see %public/www.rebol.com/   in the block?
so what you do is, for any dir,
foreach file read dir [do-something-with dir/:file]
>> print-dir: func [dir] [foreach file read dir [print dir/:file]]
>> print-dir %public/www.rebol.com/
public/www.rebol.com/index.r
public/www.rebol.com/docs/
public/www.rebol.com/bay.jpg
public/www.rebol.com/view/
public/www.rebol.com/downloads/
>> print-dir %/
/c/
/d/
/e/
/f/
/g/
/h/
/z/
Gregg
7-Jul-2007
[8395]
Petr, my file-list stuff should be on REBOL.org.
Pekr
7-Jul-2007
[8396x3]
gabriele - how does it relate to my report?
I strictly refuse following result:

>> exists? %rebol.exe
== true
>> exists? %c/
== false
both queried items are result of regular 'read function call on filesystem 
...
Chris
7-Jul-2007
[8399]
>> change-dir %/
== %/
>> exists? %c/
== true
Pekr
7-Jul-2007
[8400x2]
still does not explain my results
what is first slash representing? It is a root-dir? Then it might 
make sense. Or is it just a syntax?
Chris
7-Jul-2007
[8402]
Yes, filesystem root.
Pekr
7-Jul-2007
[8403]
then your example stands for something like following?

>> exists? join %/ %c/
== true
Chris
7-Jul-2007
[8404]
Yep.
Pekr
7-Jul-2007
[8405x2]
so that %c/, even if being a drive assigned letter, is being treated 
as a directory here ....
hmm, ok, I will remember it, but it might confuse some ppl ....
Chris
7-Jul-2007
[8407]
Yes.  I think this is Rebol's way of handling Windows unique drive 
system.
Pekr
7-Jul-2007
[8408x3]
Sunanda - here is one fine doc about all possible modes - http://rebol.com/docs/changes.html#section-6.2
somehow can't set-modes for directory :-)
is there a bug or what? Can copy-modes be set for directory too?

>> modes: get-modes %sqlite/ get-modes %sqlite/ 'copy-modes

== [creation-date: 2-Jul-2007/10:20:05+2:00 access-date: 2-Jul-2007/10:20:07+2:00 
modification-date: 2-Jul-2007/
10:20:07+2:00 owner...

>> set-modes %sqlite/ modes
** Access Error: Cannot open /c/!rebol/view/sqlite/
** Near: set-modes %sqlite/ modes


I simply wanted also my copied directories, not only files, to carry 
on original attributes ....
Brock
7-Jul-2007
[8411x3]
Pekr, 
>>exists %/c/
= true
... even when not in the root directory.
>> exists? %/c/
== true
>> what-dir
== %/C/Program Files/rebol/view/
>>
Gabriele
8-Jul-2007
[8414]
Petr, I'm not sure what you want. Obviously %c/ is a dir, and obviously 
it is at the root, so you have to access it as %/c/. This is called 
platform independent file paths. It's the same for all platforms.
Pekr
8-Jul-2007
[8415x2]
Brock, I was confused about reading %/ and getting %c/ instead of 
%/c/, that is all. I did not regarded %/ a root, I thought it is 
just a helper, as %. is .... that dot surely is not real part of 
filesystem, is it?
I resolved it for myself by defining root: %/ and joining it with 
the result of the read, works .... new problem for me is how to set 
attributes of copied directory. Not sure why do I receive error. 
It seems like that dir would be locked or so, but not sure why set-modes 
fail. Is set-modes supposed to work with directories?
Graham
8-Jul-2007
[8417x2]
no
I reported this a couple of years ago .. it does not work
Pekr
8-Jul-2007
[8419x2]
ok, thanks a lot ... it is a pity, I don't need it in fact, but found 
that possibility in docs, tried it, and it nicely works for files 
....
and is there a way to create directory not using make-dir, directly 
setting such attributes during creation process, not later?
Gabriele
8-Jul-2007
[8421]
Petr, that dot (%./) *is* part of the filesystem in most filesystems.
Pekr
9-Jul-2007
[8422]
Can I get following solved somehow, without defining globally visible 
word?

report: does [print item]
foreach item [1 2 3][report item]