Skip navigation
Currently Being Moderated

Failure loading data from Local File

Jan 5, 2011 5:14 AM

Hi All,

 

So I'm assuming that this is just a sandbox violation issue, that alchemy just plain blocks local file system access by anything that isn't an AS3 object capable of doing so (such as the file class.) I'd just like to get a solid confirmation from an employee or someone else who can give me a confirmation on this. Basically here's what I'm doing in C++

 

//Get the file class

flash_filesystem_namespace = AS3_String("flash.filesystem");

File_class = AS3_NSGetS(flash_filesystem_namespace, "File");

AS3_Val fileObject = AS3_New(File_class, emptyParams);

//

 

//Get the bytearray class

flash_utils_namespace = AS3_String("flash.utils");

ByteArray_class = AS3_NSGetS(flash_utils_namespace, "ByteArray");

AS3_Val byteArray = AS3_New(ByteArray_class, emptyParams);

//

 

 

AS3_SetS(fileObject, "nativePath", AS3_String(fileOne.c_str()));     /// ------ fileOne is of type string and I'm passing it in as an arg

 

AS3_Val doesFileRefExist = AS3_GetS(fileObject, "exists");

if(doesFileRefExist == AS3_False()){

     AS3_Call(actionscriptCallbackFunction, parentClass, AS3_Array("StrType", "File Does Not Exist"));

}

 

if(doesFileRefExist == AS3_True()){

     fileObject = AS3_CallS("resolvePath", parentClass, AS3_Array("StrType", fileOne.c_str()));          ---This works

}

 

So that works if I import and use a flash.filesystem.File object to check and see if the file exists locally. However this doesn't work:

 

bool doesFileExist(string* fName)

{

bool exists = false;

 

string tmpfName = *fName;

fstream fileToCheck;

fileToCheck.open(tmpfName.c_str(),ios::in);

if( fileToCheck.is_open() )

{

     exists=true;

}

fileToCheck.close();

 

return exists;

}

 

My function to check and see if the file exists always returns false, static of course the file doesn't exist. I've compiled this project into an executable before so I can verify that it's not my code.

 

It's also important to note that I'm compiling this into an AIR 2.5 project, so I assumed that my compiled C++ code would inherit the same permissions (local file io). Any clarification/confirmation on this would be great and thanks in advance.

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points