/* Free the volume and all associated data from memory. All dirty sectors are flushed to disk. */ CoreResult coreDropVolume(CryptedVolume * pVolume) { CoreResult cr; unsigned int i; /* Drop all files. This will flush all dirty sectors and close all open storage files. */ for (i = 0; i < FILE_HASH_TABLE_SIZE; i++) { while (pVolume->FileHashTable[i]) { cr = dropFile(pVolume->FileHashTable[i]); if (cr) return cr; /* !!! Is this good? Drop anyway? */ } } assert(pVolume->csInCache == 0); assert(pVolume->csDirty == 0); /* Free the base path. */ free(pVolume->pszBasePath); /* Free the CryptedVolume. */ free(pVolume); return CORERC_OK; }
void dropFile_(FileId id) { std::string warning; HANDLE_EXCEPTIONS(dropFile(id, warning)); if ( not warning.empty() ) elog(WARNING, warning.c_str()); }
/* Reduce the number of CryptedFile structures maintained in memory to cFiles. All references to CryptedFile structures on this volume may be invalid after calling this function. */ static CoreResult shrinkCryptedFiles(CryptedVolume * pVolume, unsigned int cFiles) { CoreResult cr; while (pVolume->cCryptedFiles > cFiles) { cr = dropFile(pVolume->pLastFile); if (cr) return cr; } return CORERC_OK; }
void ProjectWindow::contextMenuEvent(QContextMenuEvent * /* event */) { if (projectFileName == "") { QMenu menu(tr("Project menu")); menu.addAction(tr("New project"), this, SLOT(newProject())); menu.addAction(tr("Open project"), this, SLOT(openProject())); menu.addAction(tr("ignore"), this, SLOT(ignore())); menu.exec(QCursor::pos()); } else { QMenu menu(tr("Project menu")); menu.addAction(tr("Add file to project"), this, SLOT(addFile())); menu.addAction(tr("Open file in editor"), this, SLOT(editFile())); menu.addAction(tr("Drop file from project"), this, SLOT(dropFile())); menu.addAction(tr("Close project"), this, SLOT(closeProject())); menu.addAction(tr("ignore"), this, SLOT(ignore())); menu.exec(QCursor::pos()); } }
/** * Implementation of sql function with the same name * * create function * drop_file(id bigint) returns void */ Datum drop_file(PG_FUNCTION_ARGS) { if ( PG_ARGISNULL(0) ) ereport(ERROR, (errcode( ERRCODE_RAISE_EXCEPTION ), errmsg("NULL argument not allowed"))); int64 id = PG_GETARG_INT64(0); std::string warning; // WARNING: // Do not use any postgres functionality within this macro // It will cause a resource leak. HANDLE_EXCEPTIONS(dropFile(id, warning)); if ( not warning.empty() ) elog(WARNING, warning.c_str()); PG_RETURN_NULL(); }
/* Create a file with the given ID and initial size. The content of the allocated sectors is undefined (and reading them will give a CRC error with high probability). The initial size is advisory only (see coreSuggestFileSize). */ CoreResult coreCreateFile(CryptedVolume * pVolume, CryptedFileID id, SectorNumber csPreallocate) { CoreResult cr; CryptedFile * pFile; if (pVolume->parms.fReadOnly) return CORERC_READ_ONLY; if (storageFileExists(pVolume, id)) return CORERC_ID_EXISTS; /* Create a CryptedFile for this file. */ cr = accessFile(pVolume, id, &pFile); if (cr) return cr; /* Create a storage file. */ cr = openStorageFile(pFile, true, csPreallocate * SECTOR_SIZE); if (cr) { dropFile(pFile); return cr; } return CORERC_OK; }
/* Destroy the specified file. This means freeing all the file's resources in memory (see dropFile()) and deleting the associated storage file. */ CoreResult coreDestroyFile(CryptedVolume * pVolume, CryptedFileID id) { CoreResult cr; char szPathName[MAX_STORAGE_PATH_NAME]; CryptedFile * pFile; if (pVolume->parms.fReadOnly) return CORERC_READ_ONLY; cr = accessFile(pVolume, id, &pFile); if (cr) return cr; makeStoragePathName(pVolume, pFile->id, szPathName); /* Delete all the file's sectors from the cache without flushing to disk. */ deleteHighSectors(pFile, 0); /* Drop the crypted file. This will close the storage file. */ cr = dropFile(pFile); if (cr) return cr; /* Delete the storage file. */ return sys2core(sysDeleteFile(szPathName, true, pVolume->parms.cred)); }
int main(int argc, char **argv) { int correctAddDelete = 0; if(argIs("/CAD")) // Correct Add Delete { correctAddDelete = 1; } if(argIs("/M")) // Make sabun { char *beforeDir; char *afterDir; char *outDir; char *sabunFile; cout("+----------------------------+\n"); cout("| 変更前のフォルダをドロップ |\n"); cout("+----------------------------+\n"); beforeDir = dropDir(); cout("+----------------------------+\n"); cout("| 変更後のフォルダをドロップ |\n"); cout("+----------------------------+\n"); afterDir = dropDir(); outDir = makeTempDir(NULL); sabunFile = combine(outDir, "Sabun.bin"); makeSabun(sabunFile, beforeDir, afterDir, correctAddDelete); execute_x(xcout("START %s", outDir)); memFree(beforeDir); memFree(afterDir); memFree(outDir); memFree(sabunFile); } else // 差分適用 { char *targetDir; char *sabunFile; cout("+----------------------------------+\n"); cout("| 対象フォルダをドロップ |\n"); cout("| * このフォルダの中身を更新します |\n"); cout("+----------------------------------+\n"); targetDir = dropDir(); cout("+------------------------+\n"); cout("| 差分ファイルをドロップ |\n"); cout("+------------------------+\n"); sabunFile = dropFile(); cout("\n"); cout("対象フォルダを変更します。\n"); cout("処理を開始してからはキャンセル出来ません。\n"); cout("続行するにはエンターキーを押してね。\n"); if(clearGetKey() == 0x0d) { cout("\n"); cout("アップデートしています..."); if(sabunUpdate(sabunFile, targetDir) == 0) // ? アップデート対象外だった。 { cout("\r"); cout("+----------------------------+\n"); cout("| エラー/アップデート対象外 |\n"); cout("+----------------------------+\n"); } else cout("\rアップデートは完了しました。\n"); clearWaitKey(5000); // 見えるように } memFree(targetDir); memFree(sabunFile); } }
int main(int argc, char *argv[]) { if (argc != 2) { showUsage(argv[0]); return 1; } if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { showUsage(argv[0]); return 0; } if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) { showCopyright(argv[0]); return 0; } char *temp = (char *)malloc(strlen(argv[1]) + 1 + 1); sprintf(temp, "%s%%", argv[1]); char *term = correctSlash(temp); free(temp); sqlite3 *db = getDatabase(); if (!db) { showError("no database-connection"); free(term); return 1; } int rc; sqlite3_stmt *stmt; rc = sqlite3_prepare_v2(db, "SELECT name FROM directory WHERE name LIKE ? ORDER BY name ASC;", -1, &stmt, NULL); if (rc != SQLITE_OK) { showError(sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); free(term); return 1; } rc = sqlite3_bind_text(stmt, 1, term, strlen(term), SQLITE_STATIC); if (rc != SQLITE_OK) { showError(sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); free(term); return 1; } size_t count = 0; const char *dir; while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { ++count; dir = (char *)sqlite3_column_text(stmt, 0); printf("%s\n", dir); if (dropFile(db, dir)) { showError(sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); free(term); return 1; } if (dropDirectory(db, dir)) { showError(sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); free(term); return 1; } } switch (count) { case 0: printf("no directory dropped\n"); break; case 1: printf("1 directory dropped\n"); break; default: printf("%ld directories dropped\n", count); } sqlite3_finalize(stmt); sqlite3_close(db); return 0; }