1
0

remove.cpp 941 B

12345678910111213141516171819202122232425262728293031
  1. #include "main.h"
  2. #include "api_mldb.h"
  3. // returns 0 on success
  4. // returns 1 on failure of either bad filename or invalid table
  5. int RemoveFileFromDB(const wchar_t *filename)
  6. {
  7. // From mldbApi
  8. int ret = 1;
  9. if (!g_table) openDb();
  10. if (filename && g_table)
  11. {
  12. // Issue wasabi callback for pre removal
  13. WASABI_API_SYSCB->syscb_issueCallback(api_mldb::SYSCALLBACK, api_mldb::MLDB_FILE_REMOVED_PRE, (size_t)filename, 0);
  14. EnterCriticalSection(&g_db_cs);
  15. nde_scanner_t s = NDE_Table_CreateScanner(g_table);
  16. if (NDE_Scanner_LocateFilename(s, MAINTABLE_ID_FILENAME, FIRST_RECORD, filename))
  17. {
  18. NDE_Scanner_Delete(s);
  19. NDE_Scanner_Post(s);
  20. g_table_dirty++;
  21. ret = 0;
  22. }
  23. NDE_Table_DestroyScanner(g_table, s);
  24. LeaveCriticalSection(&g_db_cs);
  25. // Issue wasabi callback for post removal
  26. WASABI_API_SYSCB->syscb_issueCallback(api_mldb::SYSCALLBACK, api_mldb::MLDB_FILE_REMOVED_POST, (size_t)filename, 0);
  27. }
  28. return ret;
  29. }