| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| The ooRexx website 'products' page suggests that the rexxutil part of oorexx is supplied on all versions, whereas only Windows versions have OLE/ActiveX, ooDialog and WSH support. The ooRexx reference manual suggests that quite a lot of the rexxutil functions only work on Windows and linux. Is that actually the case? I think I'm going to write some simple CLI utilities that look at files maintained by my email client. I use that client under XP, but it's also available under Linux and Mac OS X, and I'd like to write code in a way that would be usable by other users of the same client, regardless of the platform they use it on. I see that quite a few of the SysFileXxxxx functions are described as Windows-only. And indeed there's some strange omissions even in Windows-land, eg there doesn't seem to be a Sys... function for renaming a file. So, does anyone have a set of file-handling functions that work cross- platform? I don't much want to reinvent a wheel, especially as I have neither linux nor Mac OS X machines to test things on. -- Jeremy C B Nicoll - my opinions are my own. |
|
#2
| |||
| |||
| Jeremy Nicoll - news posts wrote: > I see that quite a few of the SysFileXxxxx functions are described as > Windows-only. The scope of SysFileXxxx API's was extended a while back, greatly filling in holes that IBM had left. For the most part, if a Windows API happened to be available to do XYZ, then it was wrapped in RexxUtil exposing the API to ooRexx. Linux did not have many API's that Windows happened to have, thus it was not a simple matter of wrapping the API to expose it to ooRexx, therefor the work has been tabled. It was suggested by some in the Linux community to invoke existing system binaries, thus start a process, handle the return code, etc... Sounded very convoluted to me. My thinking was there is the need for an API to cp or mv that cp / mv calls to do the work, and that API could be wrapped to expose it to ooRexx. There is no need for the cp / mv command's screen I/O, no need for --help switch, etc... that is all UI stuff. Anyway... "someday". Because that stuff in Linux is licensed with GPL, and ooRexx with a license incompatible with GPL, it is impossible to simply harvest the API out of the OS and put the necessary portion into ooRexx. > And indeed there's some strange omissions even in > Windows-land, eg there doesn't seem to be a Sys... function for renaming a > file. At the API level on Windows, I seem to recall that there was only an API to either Move or Rename, but not both. The one serves well in the absence of the other. -- Michael Lueck Lueck Data Systems http://www.lueckdatasystems.com/ |
|
#3
| |||
| |||
| Hi Jeremy, Jeremy Nicoll - news posts wrote: > The ooRexx website 'products' page suggests that the rexxutil part of oorexx > is supplied on all versions, whereas only Windows versions have OLE/ActiveX, > ooDialog and WSH support. > > The ooRexx reference manual suggests that quite a lot of the rexxutil > functions only work on Windows and linux. Is that actually the case? > > I think I'm going to write some simple CLI utilities that look at files > maintained by my email client. I use that client under XP, but it's also > available under Linux and Mac OS X, and I'd like to write code in a way that > would be usable by other users of the same client, regardless of the > platform they use it on. > > I see that quite a few of the SysFileXxxxx functions are described as > Windows-only. And indeed there's some strange omissions even in > Windows-land, eg there doesn't seem to be a Sys... function for renaming a > file. > > So, does anyone have a set of file-handling functions that work cross- > platform? I don't much want to reinvent a wheel, especially as I have > neither linux nor Mac OS X machines to test things on. > if you are looking for cross-platform support, then I would suggest you to look into BSF4Rexx which enables Rexx programs to get access to Java. As practically every computer on this world has a Java Runtime Environment (JRE) installed, you would find an incredible wealth of functionality there. One of the nice things about this is, that the Java people had already to count in the differences of the different operating system platforms. The ooRexx support (programmed in the module "BSF.CLS") of BSF4Rexx camouflages all of Java as if it was ooRexx. This way you can refer to Java classes and Java objects with the ooRexx means. The only thing you need to be able to do here, is to read the Java documentation (linked HTML files). To stress the point w.r.t. your case (getting file related information) you could look at the "getFileInfo.rex" example distributed with BSF4Rexx (subdirectory "samples"). It uses the Java class that relates to files, the documentation to that class and the functionality being available with it could be found e.g. at <http://java.sun.com/javase/6/docs/api/java/io/File.html>. Here's a fully functional ooRexx script that accepts a file/directory name at the command line and gives some information about it: ------------------- cut here ----------------------- parse arg filename /* get the name of a file/directory */ say "received filename: --->" pp(filename) "<---" say f=.bsf~new("java.io.File",filename) -- create a Java file object say "Separator on this system: " pp(f~separator) -- get field value and show it say "Path separator on this system:" pp(f~pathSeparator) -- get field value and show it say /* define an array with two elements (strings) */ infos=.array~of( "isDirectory isFile isHidden canRead canWrite getName getPath isAbsolute" - "getAbsolutePath getCanonicalPath" , - "getAbsoluteFile getCanonicalFile toURI toURL" ) do j=1 to 2 /* iterate over the two array elements */ tmp=infos[j] /* get array-element (a string) */ do i=1 to tmp~words /* could have been: "words(infos)" */ w=tmp~word(i) /* could have been: "word(infos,i)" */ if j=1 then /* these methods return a string already */ val=.message~new(f, w)~send /* define message, give target and messagename */ else /* these methods return a Java object, hence get string off of it */ val=.message~new(f, w)~send~toString /* show results */ say " " (w":")~right(20) pp(val) /* run the method and display result */ end say "---" end ::requires BSF.CLS -- get the BSF4Rexx support for ooRexx ------------------- cut here ----------------------- Here are some invocations and their results (running on Windows in this case): ------------------- cut here ----------------------- F:\test\bsf4rexx\file>getFileInfo.rex received filename: ---> [] <--- Separator on this system: [\] Path separator on this system: [;] isDirectory: [0] isFile: [0] isHidden: [0] canRead: [0] canWrite: [0] getName: [] getPath: [] isAbsolute: [0] getAbsolutePath: [F:\test\bsf4rexx\file] getCanonicalPath: [F:\test\bsf4rexx\file] --- getAbsoluteFile: [F:\test\bsf4rexx\file] getCanonicalFile: [F:\test\bsf4rexx\file] toURI: [file:/F:/test/bsf4rexx/file/] toURL: [file:/F:/test/bsf4rexx/file] --- F:\test\bsf4rexx\file>getFileInfo.rex getFileInfo.rex received filename: ---> [getFileInfo.rex] <--- Separator on this system: [\] Path separator on this system: [;] isDirectory: [0] isFile: [1] isHidden: [0] canRead: [1] canWrite: [1] getName: [getFileInfo.rex] getPath: [getFileInfo.rex] isAbsolute: [0] getAbsolutePath: [F:\test\bsf4rexx\file\getFileInfo.rex] getCanonicalPath: [F:\test\bsf4rexx\file\getFileInfo.rex] --- getAbsoluteFile: [F:\test\bsf4rexx\file\getFileInfo.rex] getCanonicalFile: [F:\test\bsf4rexx\file\getFileInfo.rex] toURI: [file:/F:/test/bsf4rexx/file/getFileInfo.rex] toURL: [file:/F:/test/bsf4rexx/file/getFileInfo.rex] --- F:\test\bsf4rexx\file>getFileInfo.rex .. received filename: ---> [..] <--- Separator on this system: [\] Path separator on this system: [;] isDirectory: [1] isFile: [0] isHidden: [0] canRead: [1] canWrite: [1] getName: [..] getPath: [..] isAbsolute: [0] getAbsolutePath: [F:\test\bsf4rexx\file\..] getCanonicalPath: [F:\test\bsf4rexx] --- getAbsoluteFile: [F:\test\bsf4rexx\file\..] getCanonicalFile: [F:\test\bsf4rexx] toURI: [file:/F:/test/bsf4rexx/file/../] toURL: [file:/F:/test/bsf4rexx/file/../] --- ------------------- cut here ----------------------- The above program will run unchanged on Linux, Mac and Windows. So what I would suggest in your case is to use BSF4RExx, create an ooRexx module containing public routines that would supply file-related information as you see best fit. These routines, if using BSF4Rexx would be platform independent due to Java's platform independentness! HTH, ---rony |
|
#4
| |||
| |||
| > The ooRexx reference manual suggests that quite a lot of the rexxutil > functions only work on Windows and linux. Is that actually the case? Yes, even if such a situation was avoidable, e.g. with a better design and some attention. Amateurs managing a programming language. > And indeed there's some strange omissions even in Windows-land Not strange. There are a few API's and C functions which return some novice result directly, and only those were "added". E.g.: SysCos(): browse through C libararies, discover cos(), add it and don't ever wonder why that made in into the standard RexxUtil.DLL (instead of e.g. a separated Math.DLL). > there doesn't seem to be a Sys... function for renaming a file. They obviously didn't care about functions related to basic operations with files, nor any compatability-related issues. There's probably no DosFileRename()-API, so there's no SysFileRename(), and forget about SysMoveObject() at all. > does anyone have a set of file-handling functions that work cross- > platform? ooRexx doesn't, despite that being called "greatly" instead of broken. If your platform isn't on the ooRexx-list, you're on your own. And its likely ooRexx will inherit those design flaws forever. --- |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.