// Returns the home folder, or an empty string on failure. const StringBuffer& PlatformAdapter::getConfigFolder() { if (configFolder.empty()){ configFolder = getenv("XDG_CONFIG_HOME"); if (configFolder.empty()){ configFolder = getHomeFolder(); #if not defined(FUN_IPHONE) configFolder += "/.config"; #endif } configFolder += "/"; configFolder += appContext; } return configFolder; }
static char* test_object_persistence() { LCMemoryStoreRef store = LCMemoryStoreCreate(); char *memoryTest = test_object_persistence_with_store(LCMemoryStoreStoreObject(store), "memory"); if (memoryTest) { return memoryTest; } LCStringRef homeFolder = getHomeFolder(); char *strings[] = {LCStringChars(homeFolder), "/testing/"}; LCStringRef testPath = LCStringCreateFromStringArray(strings, 2); LCFileStoreRef fileStore = LCFileStoreCreate(LCStringChars(testPath)); char *fileTest = test_object_persistence_with_store(LCFileStoreStoreObject(fileStore), "file"); //deleteDirectory(LCStringChars(testPath)); return fileTest; }
//--------------------------------------------------------------------------------------------------- SFString configPath(const SFString& part) { return getHomeFolder() + ".ethslurp" + (isTesting?".test":EMPTY) + "/" + part; }
//-------------------------------------------------------------------------------- int main(int argc, const char * argv[]) { // We handle options early because the later code may // depend on them (-verbose, -testing, -help, --file) SFString cmdFile=EMPTY; for (int i=0;i<argc;i++) { SFString arg = argv[i]; if (arg.startsWith("--file:")) { cmdFile = arg.Substitute("--file:",EMPTY); cmdFile.Replace("~/",getHomeFolder()); if (!SFos::fileExists(cmdFile)) return usage("--file: '" + cmdFile + "' not found. Quitting."); } else if (arg == "-h" || arg == "-help" || arg == "--help") { return usage(); } else if (arg.startsWith("-v") || arg.startsWith("-verbose")) { verbose = TRUE; arg.Replace("-verbose",EMPTY); arg.Replace("-v", EMPTY); arg.Replace(":", EMPTY); if (!arg.IsEmpty()) verbose = toLong(arg); } else if (arg=="-t" || arg=="-test" || arg=="-titles") { // During testing, we send all output (including error messages) // to the screen so it can be re-directed to a file outErr = outScreen; isTesting = TRUE; } } // If we have a command file, we will use it, if not we will create // one and pretend we had one. This makes the processing code easier. SFString commandList; if (cmdFile.IsEmpty()) { for (int i=1;i<argc;i++) // we know the program's name commandList += (SFString(argv[i]) + " "); commandList += '\n'; } else { commandList = asciiFileToString(cmdFile).Substitute("\t", " ").Substitute(" ", " "); } // We keep only a single slurper. If the user is using the --file option and they // are reading the same account repeatedly, we only need to read the cache once. CSlurperApp slurper; // For each command we first parse the options (expanding them if neceassary), then setup // the sluper, then read from either cache or the blockchain, then display the results. while (!commandList.IsEmpty()) { SFString command = StripAny(nextTokenClear(commandList, '\n'),"\t\r\n "); if (!command.IsEmpty() && !command.startsWith(";")) // ignore comments { outErr << "Processing: " << command << "\n"; SFInt32 nArgs=0; SFString args[40]; // safe enough while (!command.IsEmpty()) { SFString arg = nextTokenClear(command, ' '); while (!arg.IsEmpty()) args[nArgs++] = expandOption(arg); // handles case of -rf for example } SFString message; // Parse the command line COptions options; options.cmdFile=!cmdFile.IsEmpty(); if (!options.parseArguments(nArgs, args)) return FALSE; // Setup the slurper if (!slurper.Initialize(options, message)) return usage(message); // Slurp the address... if (!slurper.Slurp(options, message)) return usage(message); // Apply the filters if any... if (!slurper.Filter(options, message)) return usage(message); // Report on the address... if (!slurper.Display(options, message)) return usage(message); } } return FALSE; }