Exemple #1
0
String FileLog::MakeLogFileName( const String& fileName )
{
	String logDir = GetStorageDirectory() + "Logs/";
	#if defined(WIN32)
		// logDir is already sufficient
	#elif defined(__APPLE__)
		MakeDirectories(logDir);
	#elif defined(__linux__)
		// logDir is already sufficient
	#endif
	
	return logDir + fileName + ".log";
}
Exemple #2
0
bool SaveGameIterator::RescanSaveGames()
{
	// delete old entries
	save_slots.clear();

	char Path[_MAX_PATH];
	PathJoin(Path, core->SavePath, SaveDir(), NULL);

	DirectoryIterator dir(Path);
	// create the save game directory at first access
	if (!dir) {
		if (!MakeDirectories(Path)) {
			Log(ERROR, "SaveGameIterator", "Unable to create save game directory '%s'", Path);
			return false;
		}
		dir.Rewind();
	}
	if (!dir) { //If we cannot open the Directory
		return false;
	}

	std::set<char*,iless> slots;
	do {
		const char *name = dir.GetName();
		if (dir.IsDirectory() && IsSaveGameSlot( Path, name )) {
			slots.insert(strdup(name));
		}
	} while (++dir);

	for (std::set<char*,iless>::iterator i = slots.begin(); i != slots.end(); i++) {
		save_slots.push_back(BuildSaveGame(*i));
		free(*i);
	}

	return true;
}
Exemple #3
0
const String Preferences::GetUserPrefsPath()
{
    MakeDirectories(GetStorageDirectory());
    return GetStorageDirectory() + "user_prefs.lua";
}
int
main(int argc, const char** argv) {
  CCommandLine arguments;
  arguments.ParseArgumentVector(argc, argv);
  deque<string> sourceFiles;
  string classPathString;
  CFilePath* classDestinationBase = 0;
  bool dependMode = false;

  if (arguments.GetArgumentCount() < 1) {
    SyntaxAbort(arguments.GetCommand());
  }
  for (CCommandLine::ArgumentIteratorType arg = arguments.GetArgumentBegin();
       arg != arguments.GetArgumentEnd(); ++arg) {
    unsigned long optionLength = (*arg).length();
    if (*arg == "-classpath") {
      ++arg;
      if (arg == arguments.GetArgumentEnd()) {
	SyntaxAbort(arguments.GetCommand());
      } else {
	classPathString = *arg;
      }
    } else if (*arg == "-version") {
      cerr << "guavac version " << VERSION << endl;
    } else if (*arg == "-M") {
      dependMode = true;
    } else if (*arg == "-d") {
      ++arg;
      if (arg == arguments.GetArgumentEnd()) {
	SyntaxAbort(arguments.GetCommand());
      } else {
	delete classDestinationBase;
	classDestinationBase = new CFilePath(*arg);
	if (!classDestinationBase->IsDirectory()) {
	  cerr << ">> Invalid destination directory: " << *arg << endl;
	  delete classDestinationBase;
	  classDestinationBase = 0;
	}
      }
    } else if (optionLength > 0 && (*arg)[0] == '-') {
      cerr << ">> Invalid compiler flag: " << *arg << endl;
      SyntaxAbort(arguments.GetCommand());
    } else {
      CFilePath filePath(*arg);
      if (!filePath.IsFile()) {
	cerr << ">> Invalid argument (not a plain file): " << *arg << endl;
	SyntaxAbort(arguments.GetCommand());
      } else if (optionLength < kSourceSuffix.length() ||
		 (*arg).compare(".java",
				optionLength - kSourceSuffix.length()) != 0) {
	cerr << ">> Invalid source file (no .java suffix): " << *arg << endl;
	SyntaxAbort(arguments.GetCommand());
      } else {
	sourceFiles.push_back(*arg);
      }
    }
  }
  if (classPathString.size() == 0) {
    const char* classPathEnvironment = getenv("CLASSPATH");
    if (classPathEnvironment == 0) {
      classPathString = DEFAULT_CLASSPATH;
    } else {
      classPathString = classPathEnvironment;
    }
  }
  if (sourceFiles.size() == 0) {
    cerr << ">> No valid source file names given." << endl;
    exit(1);
  }
  deque<string> classPath;
  if (! ParseClassPath(classPathString, classPath)) {
    cerr << ">> Invalid class path: " << classPathString << endl;
    exit(1);
  }
  bool success = true;
  for (deque<string>::const_iterator sourceIterator = sourceFiles.begin();
       success && !(sourceIterator == sourceFiles.end()); ++sourceIterator) {
    string fileName = *sourceIterator;
    string::size_type lastSlash = fileName.find_last_of('/');
    if (lastSlash == string::npos) {
      lastSlash = 0;
    } else {
      lastSlash++;
    }
    string fileDirectory(fileName, 0, lastSlash);
    CCompiler::ClassList resultClasses;
    deque<string> depends;
    success &= 
      CCompiler::CompileFile(fileName, classPath, resultClasses, depends);
    if (success) {
      if (!dependMode) {
	cout << "Compilation Successful.  Classes/interfaces found:" << endl;
      }
      for (CCompiler::ClassList::iterator i = resultClasses.begin();
	   i != resultClasses.end(); ++i) {
	string className = ::UnicodeToString((*i)->GetShortName());
	string outFileName;
	if (classDestinationBase == 0) {
	  outFileName = fileDirectory + className + ".class";
	} else {
	  outFileName = classDestinationBase->GetString() + "/" +
	    ::UnicodeToString((*i)->GetClassName()) + ".class";
	}
	if (dependMode) {
	  cout << outFileName << ":";
	  for (deque<string>::iterator iter = depends.begin();
	       !(iter == depends.end()); ++iter) {
	    cout << " \\\n        " << *iter;
	  }
	  cout << endl;
	} else if (MakeDirectories(outFileName)) {
	  ofstream outFile;
	  outFile.open(outFileName.c_str(), ios::out | ios::bin | ios::trunc);
	  if (!outFile.is_open()) {
	    cerr << ">> could not open output file " << outFileName << endl;
	  } else {
	    if (!(*i)->IsInner()) {
	      cout << " *  " << className << endl;
	    }
	    (*i)->Compile(outFile);
	    outFile.close();
	  }
	}
      }
    } else {
      cerr << "Compilation Failed" << endl;
    }
    for (CCompiler::ClassList::iterator i = resultClasses.begin();
	 i != resultClasses.end(); ++i) {
      delete *i;
    }
  }
  return success ? 0 : 1;
}