I know drupal_realpath is depreciated but as far as I can tell I cannot avoid using it.
I have a little module that will unzip a file and search the contents of the unzipped file and create content with the images it finds. In order to search the unzipped directory tree I need to rely on standard php methods will not work with paths like 'public://..." so I need to use drupal_realpath to massage my paths into something drupal can handle.
When I actually create the image file I do not want to use the drupal realpath because this would obviously be problematic if I migrated to a different server.
Is there a way I can turn the realpath which will look something like this:
back into something like:
If not is there some way I can search a directory structure without using drupal_realpath?
EDIT: So it seems that my problem may really only be with certain PHP lirbaries for example simpleXML.
$shape_xml = 'public://Arcade Projects/ender2012/AgentCubes/Open Arcade/Moonsweeper/version8/Moonsweeper/agents/Tutorial/shapes/Tutorial/shape.xml'; watchdog("file exists normal",file_exists($shape_xml)); watchdog("file exists real path",file_exists(drupal_realpath($shape_xml)));
In the above example, both watchdogs print 1, so it seems that file_exists works fine with the drupal path or the realpath.
But, if I call simplexml_load_file with the drupal_realpath like this:
$xml = simplexml_load_file(drupal_realpath($shape_xml));
everything works fine.
But If I call it like this:
$xml = simplexml_load_file($shape_xml);
I get the following error:
Notice: Trying to get property of non-object in harvest_icons() (line 775 of /Applications/MAMP/htdocs/drupal/sites/all/modules/custom/unzip/unzip.module).