inm logo
Corporate Website | Contact | Store | Support | Login  
     


Knowledgebase
View categorized listing of all common frequently asked questions.
Downloads
View our categorized library of downloads for all necessary manuals, software, etc.
 Article Options
Support Center » Knowledgebase » Passing an absolute path to a Java™ object
Support Page Banner
 Passing an absolute path to a Java™ object
Product:Platform:Area:Version:
Moka Xtra for DirectorWindows, MacintoshGeneral programmingall

Summary

File paths are formatted differently depending on the operating system, and there are special considerations when coding cross-platform applications that support both Mac Classic OS and Mac OS X. For this reason, Moka Xtra has a built in function, moka_Path(), which converts a Mac Classic formatted file path to the format needed by Java™, depending on the end-user's operating system.

moka_Path() accepts a string that contains a properly formatted path following the same conventions as used in the New() method:

  • On Windows, the folder delimiter is backslash ("\"); Windows formatted paths are not converted.
  • On Mac Classic (OS 8 & 9), the folder delimiter is colon (":"); the path is converted to the Unix format needed by Java™.
  • On Mac OS X, if you use moka_Path() with a Mac Classic path, it will convert the path; if you pass a Unix formatted path (any path containing a forward slash) moka_Path() will ignore it.

By using moka_Path() you can take advantage the Director's global variables, the moviePath and the applicationPath, which use the colon (:) folder delimiter on all Mac platforms.

Use moka_Path() as you would use a type conversion function, whenever you call a Java™ object that requires a file path.

Example

-- Example 1: passing a folder name to a Java class;   
-- must end with proper system delimiter
if (the Platform contains "Windows") then gSysDel = "\" -- backslash for Windows else gSysDel = ":" -- colon for all Mac platforms end if thePath = the moviePath & "myfolder" & gSysDel -- convert the path within the Moka Xtra method call gFile = gMoka.moka_CreateJavaObject("java.io.File","(Ljava/lang/String;)V", \
moka_Path(thePath)
) -- Example 2: passing an absolute file path
fPath = the moviePath & "myfolder:myfile" -- convert the path within the Moka Xtra method call err = gMoka.moka_CallJavaMethod(gFile, "unzip", \
"(Ljava/util/zip/ZipEntry;Ljava/lang/String;I)I", \
theZipEntry, moka_Path(fPath),theBufferSize)


Article Details
Article ID: 60
Created On: 26 Sep 2006 11:16 AM

 This answer was helpful  This answer was not helpful

inm general footer
Services Xtras Go Products Support Gallery Store Download About Us Contact Newsroom