I have a simple program that makes a directory when it is executed:
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main(){
if(int a = mkdir("abc",0700)){
std::cout << "Failed to create: " << a << std::endl;
}
else{
std::cout << "Created." << std::endl;
}
}
It behaves differently for two different use cases:
- Running the compiled binary through Terminal
- Output:
Created.
- Output:
- Launching this program via Finder with double click.
- Output:
Failed to create: -1
- Output:
How do I make this so that launching this program via Finder creates the folder abc
without using Cocoa framework (compiles with g++ only)?