Exemplo n.º 1
0
CoreResult setHiddenFlag(CryptedVolume * pVolume,
   CryptedFileID idDir, CryptedFileID idFile, bool fHidden)
{
   CoreResult cr;
   CryptedDirEntry * pEntries, * pCur;
   bool fFound = false;
   
   cr = coreQueryDirEntries(pVolume, idDir, &pEntries);
   if (cr) {
      coreFreeDirEntries(pEntries);
      return cr;
   }

   for (pCur = pEntries; pCur; pCur = pCur->pNext)
      if (pCur->idFile == idFile) {
         fFound = true;
         if (fHidden)
            pCur->flFlags |= CDF_HIDDEN;
         else
            pCur->flFlags &= ~CDF_HIDDEN;
      }

   if (!fFound) {
      coreFreeDirEntries(pEntries);
      return CORERC_FILE_NOT_FOUND;
   }

   cr = coreSetDirEntries(pVolume, idDir, pEntries);
   coreFreeDirEntries(pEntries);
   return cr;
}
Exemplo n.º 2
0
APIRET fsRmDir(ServerData * pServerData, struct rmdir * prmdir)
{
   CoreResult cr;
   VolData * pVolData;
   CryptedVolume * pVolume;
   CHAR szName[CCHMAXPATH];
   CryptedFileID idDir;
   CryptedFileID idFile;
   CryptedDirEntry * pFirstEntry;
   
   if (VERIFYFIXED(prmdir->szName) ||
       verifyPathName(prmdir->szName))
      return ERROR_INVALID_PARAMETER;
   
   GET_VOLUME(prmdir);
   pVolume = pVolData->pVolume;
   
   logMsg(L_DBG, "FS_RMDIR, szName=%s", prmdir->szName);

   cr = findFromCurDir(pVolData, prmdir->szName, &prmdir->cdfsi,
       &prmdir->cdfsd, prmdir->iCurDirEnd, &idDir, &idFile, 0,
       szName);
   if (cr) return coreResultToOS2(cr);

   /* Yes.  Read the directory contents.  (This implicitly makes sure
      that pFile is a directory. */
   cr = coreQueryDirEntries(pVolume, idFile, &pFirstEntry);
   if (cr || pFirstEntry) {
      coreFreeDirEntries(pFirstEntry);
      return cr ? coreResultToOS2(cr) : ERROR_CURRENT_DIRECTORY;
   }

   /* The directory is empty, so we can proceed with the deletion. */

   /* Remove the directory from its parent directory. */
   cr = coreMoveDirEntry(pVolume, szName, idDir, 0, 0);
   if (cr) return coreResultToOS2(cr);

   /* Delete the directory. */
   cr = coreDeleteFile(pVolume, idFile);
   if (cr) return coreResultToOS2(cr);
   
   return NO_ERROR;
}