static int ftwCallback(const char *name, const struct stat *status, int info) { if (info == FTW_F) { fileDelete((char *)name); } return 0; }
Status pluginDataClear(const Account &account, const std::string &plugin) { std::string directory = pluginDirectory(account, plugin); if (fileExists(directory)) ABC_CHECK(fileDelete(directory)); return Status(); }
Status pluginDataRemove(const Account &account, const std::string &plugin, const std::string &key) { std::string filename = keyFilename(account, plugin, key); if (fileExists(filename)) ABC_CHECK(fileDelete(filename)); return Status(); }
static Boolean dir_delete(DirPtr dir) { if (dirNFilesSelected(dir)) { SelPtr sel = selFromDir(dir); Boolean ret = fileDelete(sel); selFree(sel); update(); return ret; } else { root_modified = cur_modified = shelf_modified = cur_changed = False; return False; } }
void HttpClient::onFinished(TcpClientState finishState) { if (finishState == eTCS_Failed) code = 0; if (mode == eHCM_File) { debugf("Download file len written: %d, res^ %d", fileTell(saveFile), isSuccessful()); if (!isSuccessful()) fileDelete(saveFile); fileClose(saveFile); } if (onCompleted) onCompleted(*this, isSuccessful()); TcpClient::onFinished(finishState); }
file_t fileOpen(const String name, FileOpenFlags flags) { int res; // Special fix to prevent known spifFS bug: manual delete file if ((flags & eFO_CreateNewAlways) == eFO_CreateNewAlways) { if (fileExist(name)) fileDelete(name); flags = (FileOpenFlags)((int)flags & ~eFO_Truncate); } res = SPIFFS_open(&_filesystemStorageHandle, name.c_str(), (spiffs_flags)flags, 0); if (res < 0) debugf("open errno %d\n", SPIFFS_errno(&_filesystemStorageHandle)); return res; }
Status syncEnsureRepo(const std::string &syncDir, const std::string &tempDir, const std::string &syncKey) { AutoSyncLock lock(gSyncMutex); if (!fileExists(syncDir)) { if (fileExists(tempDir)) ABC_CHECK(fileDelete(tempDir)); ABC_CHECK(syncMakeRepo(tempDir)); bool dirty = false; ABC_CHECK(syncRepo(tempDir, syncKey, dirty)); if (rename(tempDir.c_str(), syncDir.c_str())) return ABC_ERROR(ABC_CC_SysError, "rename failed"); } return Status(); }
void threadRFHumidity( void ) { PYGMYWIDGET *pygmyWidget; PYGMYFILE pygmyFile; u16 uiLen; static uiLock = 0; if( !socketGet( 0x13480238, 0xFFFFFFFF ) ){ //uiLock = ; //print( COM3, "\rNo Socket Found" ); if( fileOpen( &pygmyFile, "humidity.txt", READ ) ){ print( COM3, "\rFound humidity.txt" ); uiLen = fileGetBuffer( &pygmyFile, 20, globalHumidity ); if( uiLen != 0 && uiLen < 8 ){ globalHumidity[ uiLen ] = '\0'; } // if print( COM3, "\rLoaded value: %s", globalHumidity ); fileDelete( "humidity.txt" ); print( COM3, "\rDeleted humidity.txt" ); /*pygmyWidget = widgetGet( globalHumidity ); if( pygmyWidget ){ //pygmyWidget->Style = CAPTION|FILLED|VISIBLE|ROUNDED|BORDER|CENTERED; guiClearArea( colorGetRootClearColor(), pygmyWidget->X, pygmyWidget->Y, pygmyWidget->X + pygmyWidget->Width, pygmyWidget->Y+pygmyWidget->Height ); guiSetCursor( pygmyWidget->X+2, pygmyWidget->Y + 9 ); print( LCD, globalHumidity ); } // if */ //drawRFTest( ); drawForms(); } // if print( COM3, "\rRequesting humidity.txt" ); socketRequestFile( 0x13480238, "humidity.txt" ); print( COM3, "..." ); } else if( uiLock == 0 ){ uiLock = 1; socketRequestFile( 0x13480238, "humidity.txt" ); } else{ print( COM3, "Testing for File..." ); } // else }
/** * Shell command (delete) deletes existing files. * @param args array of arguments * @return OK for success, SYSERR for syntax error */ command xsh_delete(int nargs, char *args[]) { int fd = 0; char c = 0; /* Output help, if '--help' argument was supplied */ if ((nargs == 2 && strncmp(args[1], "--help", 6) == 0) || (nargs != 2)) { printf("Usage: delete [filename]\n"); printf("Print file contents or copy console input into new file.\n"); printf("\t--help\t display this help and exit\n"); return OK; } fd = fileOpen(args[1]); if (SYSERR == fd) { printf("File \"%s\" not found.\n", args[1]); return OK; } fileDelete(fd); return OK; }
void configureCFW(const char *configPath, const char *firm90Path){ initScreens(); drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE); const char *optionsText[] = { "( ) Updated SysNAND mode (A9LH-only)", "( ) Use pre-patched FIRMs", "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option options[optionsAmount]; //Read and parse the existing configuration u32 tempConfig = 0; fileRead(&tempConfig, configPath, 3); for(u32 i = 0; i < optionsAmount; i++) options[i].enabled = (tempConfig >> i) & 0x1; //Pre-select the first configuration option u32 selectedOption = 0; //Boring configuration menu while(1){ u16 pressed = 0; do{ for(u32 i = 0; i < optionsAmount; i++){ options[i].posY = drawString(optionsText[i], 10, !i ? 60 : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE); drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK); } pressed = waitInput(); } while(!(pressed & MENU_BUTTONS)); switch(pressed){ case BUTTON_UP: selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; break; case BUTTON_DOWN: selectedOption = selectedOption == optionsAmount - 1 ? 0 : selectedOption + 1; break; case BUTTON_LEFT: selectedOption = 0; break; case BUTTON_RIGHT: selectedOption = optionsAmount - 1; break; case BUTTON_A: options[selectedOption].enabled = !options[selectedOption].enabled; break; } if(pressed == BUTTON_START) break; } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM if(((tempConfig >> 16) & 0x1) && ((tempConfig & 0x1) != options[0].enabled)) fileDelete(firm90Path); //Preserve the last-used boot options (last 12 bits) tempConfig &= 0xFFF000; //Parse and write the selected options for(u32 i = 0; i < optionsAmount; i++) tempConfig |= options[i].enabled << i; fileWrite(&tempConfig, configPath, 3); //Zero the last booted FIRM flag CFG_BOOTENV = 0; //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); }
void deleteFirms(const char *firmPaths[], u32 firms){ while(firms){ fileDelete(firmPaths[firms - 1]); firms--; } }
void gpDeleteGame(char *name, featom *atom) { char filename[PATH_MAX] = ""; sdword i; sdword index; fonthandle oldfont; if (!gpGetGameName(name,atom,filename)) { return; } // gpCurrentSelected will be set by gpGetGameName feScreenDisappear(NULL, NULL); char *tmpFilePath = filePathPrepend(filename, FF_UserSettingsPath); strcpy(filename, tmpFilePath); fileDelete(filename); if (SavedGamesPath == RecordedGamesPath) { char tmpfile[PATH_MAX] = ""; strcpy(tmpfile,filename); strcat(tmpfile,PKTS_EXTENSION); fileDelete(tmpfile); } for (i=gpCurrentSelected;i<gpNumberGames-1;i++) { gpGames[i] = gpGames[i+1]; } gpNumberGames--; if (gpNumberGames == 0) { gpCurrentSelected = 0; } else if (gpCurrentSelected >= gpNumberGames) { gpCurrentSelected--; dbgAssertOrIgnore(gpCurrentSelected >= 0); dbgAssertOrIgnore(gpCurrentSelected < gpNumberGames); } dbgAssertOrIgnore(gpNumberGames >= 0); oldfont = fontMakeCurrent(gpListFont); // fontHeight called later on in this function uicListCleanUp(gpGameListWindow); uicListWindowInit(gpGameListWindow, NULL, // title draw, no title NULL, // title click process, no title 0, // title height, no title gpGameItemDraw, // item draw function fontHeight(" ")+GP_VertSpacing, // item height UICLW_CanSelect); for (index = 0; index < gpNumberGames; index++) { if (index==gpCurrentSelected) uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail); else uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail); } fontMakeCurrent(oldfont); }
void FTPServerConnection::onCommand(String cmd, String data) { cmd.toUpperCase(); debugf("FTP : cmd = %s, data = %s",cmd.c_str(),data.c_str()); // We ready to quit always :) if (cmd == "QUIT") { response(221); close(); return; } // Strong security check :) if (state == eFCS_Authorization) { if (cmd == "USER") { userName = data; response(331); } else if (cmd == "PASS") { if (server->checkUser(userName, data)) { userName = ""; state = eFCS_Active; response(230); } else response(430); } else { response(530); } return; } if (state == eFCS_Active) { if (cmd == "SYST") { response(215, "Windows_NT: Sming Framework"); // Why not? It's look like Windows :) } else if (cmd == "PWD") { response(257, "\"/\""); } else if (cmd == "PORT") { cmdPort(data); } else if (cmd == "EPRT") { cmdEPRT(data); } else if (cmd == "CWD") { if (data == "/") { directoryPrefix = ""; response(250); } else { directoryPrefix = directoryPrefix + data + "/"; response(250); } } else if (cmd == "TYPE") { // response(250); response(200); } /*else if (cmd == "SIZE") { response(213, String(fileGetSize(makeFileName(data, false)))); }*/ else if (cmd == "DELE") { String name = makeFileName(data, false); if (fileExist(name)) { fileDelete(name); response(250); } else response(550); } /*else if (cmd == "RNFR") // Bugs! { renameFrom = data; response(350); } else if (cmd == "RNTO") { if (fileExist(renameFrom)) { fileRename(renameFrom, data); response(250); } else response(550); }*/ else if (cmd == "RETR") { String name = makeFileName(data, false); if (fileExist(name)) { createDataConnection(new FTPDataRetrieve(this, makeFileName(data, false))); } else { response(550); } } else if (cmd == "STOR") { createDataConnection(new FTPDataStore(this, makeFileName(data, true))); } else if (cmd == "LIST") { createDataConnection(new FTPDataFileList(this)); } else if (cmd == "PASV") { response(500 , "Passive mode not supported"); } else if (cmd == "NOOP") { response(200); } else if (!server->onCommand(cmd, data, *this)) response(502, "Not supported"); return; } debugf("!!!CASE NOT IMPLEMENTED?!!!"); }
//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- void CApplication::confDelete() { if (confExists()) fileDelete(CAPP_CONF_FILE); } // confDelete
Status watcherDeleteCache(Wallet &self) { ABC_CHECK(fileDelete(self.paths.watcherPath())); return Status(); }
void configureCFW(const char *configPath, const char *patchedFirms[]) { initScreens(); drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE); const char *optionsText[] = { "Screen-init brightness: 4( ) 3( ) 2( ) 1( )", "( ) Updated SysNAND mode (A9LH-only)", "( ) Use pre-patched FIRMs", "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", "( ) Enable splash screen with no screen-init", "( ) Load loader from SD" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option { int posY; u32 enabled; } options[optionsAmount]; //Parse the existing configuration options[0].enabled = CONFIG(10, 3); for(u32 i = optionsAmount; i; i--) options[i].enabled = CONFIG((i - 1), 1); //Pre-select the first configuration option u32 selectedOption = 1, oldSelectedOption = 0, optionChanged = 0; //Character to display a selected option char selected = 'x'; //Starting position options[0].posY = 52; //Display all the normal options in white, brightness will be displayed later for(u32 i = 1; i < optionsAmount; i++) { options[i].posY = drawString(optionsText[i], 10, options[i - 1].posY + SPACING_Y + (!(1 - i) * 7), COLOR_WHITE); if(options[i].enabled) drawCharacter(selected, 10 + SPACING_X, options[i].posY, COLOR_WHITE); } //Boring configuration menu while(1) { u32 pressed = 0; do { //The status of the selected option changed, black out the previously visible 'x' if needed if(optionChanged) { if(!selectedOption) drawCharacter(selected, 10 + (26 + 5 * (optionChanged - 1)) * SPACING_X, options[0].posY, COLOR_BLACK); else if(!options[selectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[selectedOption].posY, COLOR_BLACK); optionChanged = 0; } //The selected option changed, draw the new one in red and the old one (with its 'x') in white else if(selectedOption != oldSelectedOption) { drawString(optionsText[oldSelectedOption], 10, options[oldSelectedOption].posY, COLOR_WHITE); drawString(optionsText[selectedOption], 10, options[selectedOption].posY, COLOR_RED); if(!oldSelectedOption) drawCharacter(selected, 10 + (26 + 5 * options[0].enabled) * SPACING_X, options[0].posY, COLOR_WHITE); else if(options[oldSelectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[oldSelectedOption].posY, COLOR_WHITE); } //In any case, if the current option is enabled (or brightness is selected) we must display a red 'x' if(!selectedOption) drawCharacter(selected, 10 + (26 + 5 * options[0].enabled) * SPACING_X, options[0].posY, COLOR_RED); else if(options[selectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[selectedOption].posY, COLOR_RED); pressed = waitInput(); } while(!(pressed & MENU_BUTTONS)); //Remember the previously selected option oldSelectedOption = selectedOption; switch(pressed) { case BUTTON_UP: selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; break; case BUTTON_DOWN: selectedOption = selectedOption == (optionsAmount - 1) ? 1 : selectedOption + 1; break; case BUTTON_LEFT: selectedOption = 1; break; case BUTTON_RIGHT: selectedOption = optionsAmount - 1; break; case BUTTON_A: optionChanged = 1; if(selectedOption) options[selectedOption].enabled = !options[selectedOption].enabled; else { optionChanged += options[0].enabled; options[0].enabled = options[0].enabled == 3 ? 0 : options[0].enabled + 1; } break; } if(pressed == BUTTON_START) break; } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM if(CONFIG(16, 1) && (CONFIG(0, 1) != options[1].enabled)) fileDelete(patchedFirms[3]); //If the "Show GBA boot screen in patched AGB_FIRM" setting changed, delete the patched AGB_FIRM if(CONFIG(6, 1) != options[7].enabled) fileDelete(patchedFirms[5]); //Preserve the last-used boot options (last 12 bits) config &= 0xFFF000; //Parse and write the new configuration config |= options[0].enabled << 10; for(u32 i = optionsAmount; i; i--) config |= options[i].enabled << (i - 1); fileWrite(&config, configPath, 3); //Zero the last booted FIRM flag CFG_BOOTENV = 0; //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); }