1 person found this helpful
Relative paths. If the EXE is in a folder which contains the "movies" folder then simply use:
thanks for replying, yes relative path will work and I have already used it simply as for e.g. movie1.flv
the problem is my client has other movies in other folders that the EXE would need to access. The simple solution would be to copy those files (movies etc) to the same folder but alas my client doesnt want to do that for some sound reasons and some not so much.
So Couldnt i type in the path as such?
You can always directly type a path. If you resolve a File (object) path in AIR the .nativePath property will give you just that, a full OS path to your file like above: C:\SHELL_MF\movies\movie1.flv.
Off the top of my head, the filesystems are so different between *nix and Windows you really can't solve it unless perhaps one of two things is an acceptible solution.
1, Use one of the folders AIRs File object has access to so you can begin appending relative paths again. They are:
File.applicationStorageDirectory—a storage directory unique to each installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory
If you can agree to use any of those folders which are outside the applications directory then you have a unified way to access it via AIR. Just resolve the local path of the file like:
var movie:File = File.documentsDirectory.resolvePath('movies/movie1.flv');
Each OS will trace a different path.
2, Consider using a bridge. I almost always use XML files to provide external data to my applications. If your client wants to wildly use random paths then you can make an XML file that contains a full path to each and every file containing the differences for each OS.
<?xml version="1.0" encoding="utf-8">
<!-- etc... -->
Then you can wildly stick anything anywhere you want. Either use the nodes index or add a simple id attribute so you can call up the movie you want and grab the proper path for the OS.
Otherwise I don't really see any way to develop the application in a unified way without specializing it for each OS and adding a bunch of hard coded paths. I'm not a fan of hard coding and I'm pretty sure you're not either. I don't like to recompile just to add a new movie.
A potential third thing would be to simply agree on the name of the folder the client can put movies in and put it in root, e.g. C:\DATA\movies and /DATA/movies. But that doesn't appear to be the case here and it makes an "unknown" dependancy that will need to be remembered. Not really ideal.