Exemple #1
0
BOOL DiskSortEntries(RDWRHandle handle, CLUSTER cluster)
{
   int  i=0;
   long totalcount, lfncount, realcount;
   struct DiskEntryGetterStruct parameters;
   struct DirectoryPosition pos;
   struct DirectoryEntry entry;

   parameters.handle = handle;
   parameters.cluster = cluster;
   
   SetResourceConfiguration(&DiskConfig);  

   totalcount = low_dircount(handle, cluster, 0xffff);
   if (totalcount == -1)
      RETURN_FTEERR(FALSE);
      
   lfncount   = low_dircount(handle, cluster, LFN_ATTRIBUTES);
   if (lfncount == -1)
      RETURN_FTEERR(FALSE);
      
   realcount = totalcount - lfncount;
   
   for (i = 0; i < 2; i++)
   {
       if (!GetNthDirectoryPosition(handle, cluster, i, &pos))
       {
          RETURN_FTEERR(FALSE);
       }
   
       if (!GetDirectory(handle, &pos, &entry))
       {
          RETURN_FTEERR(FALSE);
       }
   
       switch (i)
       {
          case 0:
               if (IsCurrentDir(entry))
               {
                  realcount--;
               }
               break;
          case 1:
               if (IsPreviousDir(entry))
               {
                  realcount--;
               }
       }
   } 
            
   if (realcount && realcount <= INT_MAX)
      SelectionSortEntries(&parameters, (int)realcount);

   return TRUE;
}
Exemple #2
0
BOOL InitDblNameChecking(RDWRHandle handle, CLUSTER cluster, char* filename)
{
    long dircount;
    
    UNUSED(filename);
    
    hashtable = (struct HashSlot*)
                malloc(sizeof(struct HashSlot) *  HASHTABLESIZE);
    if (!hashtable) return FALSE;
    
    /* Make sure all next pointers are invalidated */
    memset(hashtable, 0xff, sizeof(struct HashSlot) *  HASHTABLESIZE);    
  
    /* 0xFF means all the files in the directory */
    dircount = low_dircount(handle, cluster, 0xFF); 
    if (dircount == FAIL)                               /* FAIL == -1 */
    {
       free(hashtable);
       return FALSE;
    }

    /* Try to allocate memory for the array. */
    filenamearray = (struct ArrayElement*)
		    malloc(((unsigned)dircount) * sizeof(struct ArrayElement));
    if (!filenamearray)
    {
       free(hashtable);
       return FALSE;
    }
  
    surroundingdir = cluster;
    
    return TRUE;
}