userlibandfileserver/fileserver/sfat32/sl_file.cpp
branchRCL_3
changeset 41 0ffb4e86fcc9
parent 22 2f92ad2dc5db
child 42 a179b74831c9
equal deleted inserted replaced
39:2bb754abd467 41:0ffb4e86fcc9
    40         {//-- do some finalisation work if CMountCB is valid
    40         {//-- do some finalisation work if CMountCB is valid
    41         if(FileAttModified())
    41         if(FileAttModified())
    42             {
    42             {
    43             IndicateFileTimeModified(ETrue); //-- this will force writing file modification time to the media on Flush
    43             IndicateFileTimeModified(ETrue); //-- this will force writing file modification time to the media on Flush
    44             TRAP_IGNORE(FlushAllL());
    44             TRAP_IGNORE(FlushAllL());
    45         }
    45 	        }
    46         }
    46         }
    47 
    47 
    48     delete[] iSeekIndex;
    48     delete[] iSeekIndex;
    49 	}
    49 	}
    50 
    50 
   635 	
   635 	
   636 	if(aSize == FCB_FileSize())
   636 	if(aSize == FCB_FileSize())
   637         return;
   637         return;
   638 
   638 
   639     IndicateFileSizeModified(ETrue);
   639     IndicateFileSizeModified(ETrue);
       
   640 	IndicateFileAttModified(ETrue);		// ensure file size is flushed
   640 
   641 
   641 	TInt newIndexMult=CalcSeekIndexSize(aSize);
   642 	TInt newIndexMult=CalcSeekIndexSize(aSize);
   642 	if (iSeekIndex!=NULL && newIndexMult!=iSeekIndexSize)
   643 	if (iSeekIndex!=NULL && newIndexMult!=iSeekIndexSize)
   643 		ResizeIndex(newIndexMult,aSize);
   644 		ResizeIndex(newIndexMult,aSize);
   644 
   645 
   682     FatMount().CheckStateConsistentL();
   683     FatMount().CheckStateConsistentL();
   683     FatMount().CheckWritableL();
   684     FatMount().CheckWritableL();
   684 
   685 
   685     //-- change file attributes
   686     //-- change file attributes
   686     const TUint setAttMask = (aSetAttMask & KEntryAttMaskSupported); //-- supported attributes to set
   687     const TUint setAttMask = (aSetAttMask & KEntryAttMaskSupported); //-- supported attributes to set
   687     TUint newAtt = Att();
   688 	TUint oldAtt = Att();
       
   689 	TUint newAtt = oldAtt;
   688 
   690 
   689 	if (setAttMask|aClearAttMask)
   691 	if (setAttMask|aClearAttMask)
   690 		{
   692 		{
   691         newAtt |= setAttMask;
   693         newAtt |= setAttMask;
   692         newAtt &= ~aClearAttMask;
   694         newAtt &= ~aClearAttMask;
   693         SetAtt(newAtt);
   695 		if (newAtt != oldAtt)
   694         IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed
   696 			{
       
   697 	        SetAtt(newAtt);
       
   698 		    IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed
       
   699 			}
   695 		}
   700 		}
   696     
   701     
   697     //-- set file entry modification time if required
   702     //-- set file entry modification time if required
   698 	if (aSetAttMask&KEntryAttModified)
   703 	if (aSetAttMask&KEntryAttModified)
   699 	{
   704 		{
   700         SetModified(aTime);        //-- set file modified time
   705         SetModified(aTime);        //-- set file modified time
   701         IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed
   706         IndicateFileAttModified(ETrue); //-- indicate that file attributes have changed
   702         IndicateFileTimeModified(ETrue); //-- this will force writing file mod. time to the media on Flush
   707         IndicateFileTimeModified(ETrue); //-- this will force writing file mod. time to the media on Flush
   703         }
   708         }
   704 
   709 
   934     CFatMountCB& mount = FatMount();
   939     CFatMountCB& mount = FatMount();
   935     TFatDirEntry dirEntry;
   940     TFatDirEntry dirEntry;
   936 
   941 
   937     mount.ReadDirEntryL(iFileDosEntryPos, dirEntry); //-- read this file's dir. entry
   942     mount.ReadDirEntryL(iFileDosEntryPos, dirEntry); //-- read this file's dir. entry
   938     dirEntry.SetSize(aSize);                         //-- set new size
   943     dirEntry.SetSize(aSize);                         //-- set new size
       
   944 
       
   945 	// As we're updating the directory entry anyway, we might as well update the attributes & time 
       
   946 	// if these have been modified to save having to update them later...
       
   947 	if (FileAttModified())
       
   948 		{
       
   949 		dirEntry.SetAttributes(Att() & KEntryAttMaskSupported);
       
   950         IndicateFileAttModified(EFalse); 
       
   951 		IndicateFileTimeModified(ETrue);	//-- this mirrors the behaviour of CFatFileCB::~CFatFileCB()
       
   952 		}
       
   953 	if (FileTimeModified())
       
   954 		{
       
   955 		dirEntry.SetTime(iModified, FatMount().TimeOffset());
       
   956         IndicateFileTimeModified(EFalse);
       
   957 		}
       
   958 
   939     mount.WriteDirEntryL(iFileDosEntryPos, dirEntry);//-- write the entry back
   959     mount.WriteDirEntryL(iFileDosEntryPos, dirEntry);//-- write the entry back
   940 
   960 
   941     IndicateFileSizeModified(EFalse);
   961     IndicateFileSizeModified(EFalse);
   942     }
   962     }
   943 
   963