Reputation: 25373
The code is simple enough:
#include <iostream>
#include <fstream>
#include <string>
int main(int argc, char* argv[] )
{
std::ofstream theStream;
theStream.open("trash.txt");
theStream << "some words" << std::endl;
theStream.close();
}
If I run it from the command line then I get the expected file in the same directory. If a package the contents of the executable within a MacOS .app, then no file is written anywhere. (Or perhaps it is just promptly erased?)
Here's the simple script I'm using to place the executable into the .app. Perhaps that is where I'm going wrong.
#!/bin/bash
appName=MyApp
if [ $1 ]
then
appName=$1
else
echo "usage: convertToApp executableFile"
exit
fi
if [ -e "$appName" ]
then
mkdir $appName.app
mkdir $appName.app/Contents
mkdir $appName.app/Contents/MacOS
mkdir $appName.app/Contents/Resources
cp $appName $appName.app/Contents/MacOS/$appName
echo -n 'APPL????' > $appName.app/Contents/PkgInfo
else
echo "specified file does not exist"
fi
Any idea why I can't see the file I want to see?
Upvotes: 1
Views: 3921
Reputation: 4026
Instead of "trash.txt", try to use the full path or change the current working directory.
Upvotes: 6