Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
914 B

4 years ago
  1. #include "pdbimpl.h"
  2. #include "namemap.h"
  3. PDB_IMPORT_EXPORT(BOOL) NameMap::open(PDB* ppdb, BOOL fWrite, OUT NameMap** ppnm) {
  4. NMP* pnmp = new NMP;
  5. if (pnmp) {
  6. if (pnmp->open(ppdb, fWrite)) {
  7. *ppnm = pnmp;
  8. return TRUE;
  9. } else
  10. delete pnmp;
  11. }
  12. return FALSE;
  13. }
  14. BOOL NMP::open(PDB* ppdb, BOOL fWrite) {
  15. extern char szStreamNameMap[];
  16. if (!ppdb->OpenStream(szStreamNameMap, &pstream))
  17. return FALSE;
  18. CB cb = pstream->QueryCb();
  19. if (cb > 0) {
  20. // reload NMT from stream
  21. if (!nmt.reload(pstream))
  22. return FALSE;
  23. } else {
  24. // Nothing to do; nmt is already satisfactorily empty.
  25. }
  26. if (!fWrite) {
  27. // if read-only, release stream; will not subsequently update the PDB.
  28. pstream->Release();
  29. pstream = 0;
  30. }
  31. return TRUE;
  32. }
  33. BOOL NMP::commit() {
  34. BOOL ok = TRUE;
  35. if (pstream) ok = nmt.save(pstream);
  36. return ok;
  37. }
  38. BOOL NMP::close() {
  39. BOOL ok = commit();
  40. delete this;
  41. return ok;
  42. }