epoc32/include/eikfutil.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- a/epoc32/include/eikfutil.h	Tue Mar 16 16:12:26 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,315 +0,0 @@
     1.4 -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 -// All rights reserved.
     1.6 -// This component and the accompanying materials are made available
     1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.8 -// which accompanies this distribution, and is available
     1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 -//
    1.11 -// Initial Contributors:
    1.12 -// Nokia Corporation - initial contribution.
    1.13 -//
    1.14 -// Contributors:
    1.15 -//
    1.16 -// Description:
    1.17 -//
    1.18 -
    1.19 -#ifndef __EIKFUTIL_H__
    1.20 -#define __EIKFUTIL_H__
    1.21 -
    1.22 -#include <e32std.h>
    1.23 -#include <f32file.h>
    1.24 -#include <badesca.h>
    1.25 -#include <bautils.h>
    1.26 -#include <eikenv.h>
    1.27 -
    1.28 -class CFont;
    1.29 -class CBaflFileSortTable;
    1.30 -class TResourceReader;
    1.31 -
    1.32 -
    1.33 -/** Provides a set of drive, path and file utility functions.
    1.34 -
    1.35 -This class is essentially a thin layer over the BaflUtils class.
    1.36 -
    1.37 -@publishedAll 
    1.38 -@released */
    1.39 -NONSHARABLE_CLASS(EikFileUtils)
    1.40 -	{ 
    1.41 -public:
    1.42 -	inline static TBool PathExists(const TDesC& aPath);
    1.43 -	inline static TInt IsFolder(const TDesC& aFullName, TBool& aIsFolder);
    1.44 -	inline static TBool FolderExists(const TDesC& aFolderName);
    1.45 -	inline static TFileName FolderNameFromFullName(const TDesC& aFullName);
    1.46 -	inline static TFileName DriveAndPathFromFullName(const TDesC& aFullName);
    1.47 -	inline static TFileName RootFolderPath(const TBuf<1> aDriveLetter);
    1.48 -	inline static void AbbreviateFileName(const TFileName& aOriginalFileName, TDes& aAbbreviatedFileName);
    1.49 -	IMPORT_C static TFileName AbbreviatePath(TDesC& aPathName, const CFont& aFont, TInt aMaxWidthInPixels);
    1.50 -	inline static TBool UidTypeMatches(const TUidType& aFileUid, const TUidType& aMatchUid);
    1.51 -	inline static TInt Parse(const TDesC& aName);
    1.52 -	IMPORT_C static TFileName ValidateFolderNameTypedByUserL(const TDesC& aFolderNameTypedByUser, const TDesC& aCurrentPath);
    1.53 -	inline static TInt CopyFile(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch = CFileMan::EOverWrite);
    1.54 -	inline static TInt RenameFile(const TDesC& aOldFullName, const TDesC& aNewFullName, TUint aSwitch = CFileMan::EOverWrite);
    1.55 -	inline static TInt DeleteFile(const TDesC& aSourceFullName, TUint aSwitch=0);
    1.56 -	inline static TInt CheckWhetherFullNameRefersToFolder(const TDesC& aFullName, TBool& aIsFolder);
    1.57 -	inline static TInt MostSignificantPartOfFullName(const TDesC& aFullName, TFileName& aMostSignificantPart);
    1.58 -	inline static TInt CheckFolder(const TDesC& aFolderName);
    1.59 -	inline static TInt DiskIsReadOnly(const TDesC& aFullName, TBool& aIsReadOnly);
    1.60 -	inline static void UpdateDiskListL(const RFs& aFs,CDesCArray& aArray,TBool aIncludeRom,TDriveNumber aDriveNumber);
    1.61 -	inline static void RemoveSystemDirectory(CDir& aDir);
    1.62 -	inline static TBool IsFirstDriveForSocket(TDriveUnit aDriveUnit);
    1.63 -	inline static TInt SortByTable(CDir& aDir,CBaflFileSortTable* aTable);
    1.64 -private:
    1.65 -	EikFileUtils();
    1.66 -	};
    1.67 -
    1.68 -
    1.69 -/** Tests whether a path exists.
    1.70 -
    1.71 -@param aPath The path to check. 
    1.72 -@return ETrue if the path exists, EFalse otherwise. */
    1.73 -inline TBool EikFileUtils::PathExists(const TDesC& aPath)
    1.74 -	{	return BaflUtils::PathExists(CEikonEnv::Static()->FsSession(),aPath);	}
    1.75 -
    1.76 -/** Tests whether aFullName is a folder.
    1.77 -
    1.78 -@param aFullName The drive and path to test. 
    1.79 -@param aIsFolder On return, indicates whether aFullName is a folder. 
    1.80 -@return KErrNone if successful otherwise another of the system-wide error codes. */
    1.81 -inline TInt EikFileUtils::IsFolder(const TDesC& aFullName, TBool& aIsFolder)
    1.82 -	{	return BaflUtils::IsFolder(CEikonEnv::Static()->FsSession(), aFullName,aIsFolder);	}
    1.83 -
    1.84 -/** Tests whether a specified folder exists. 
    1.85 -
    1.86 -This returns a boolean value indicating whether the folder exists: see also 
    1.87 -CheckFolder() which returns an error code instead.
    1.88 -
    1.89 -@param aFolderName The folder's path.
    1.90 -@return ETrue if the folder exists, EFalse if not. */
    1.91 -inline TBool EikFileUtils::FolderExists(const TDesC& aFolderName)
    1.92 -	{	return BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(), aFolderName);	}
    1.93 -
    1.94 -/** Gets a folder name from a path and file name.
    1.95 -
    1.96 -@param aFullName The full path and file name from which the folder will be 
    1.97 -obtained. 
    1.98 -@return Folder name */
    1.99 -inline TFileName EikFileUtils::FolderNameFromFullName(const TDesC& aFullName)
   1.100 -	{	return BaflUtils::FolderNameFromFullName(aFullName);	}
   1.101 -
   1.102 -/** Parses the specified full path and file name to obtain the drive and path.
   1.103 -
   1.104 -@param aFullName The full path and file name from which the drive and path 
   1.105 -will be obtained. 
   1.106 -@return The drive and path. */
   1.107 -inline TFileName EikFileUtils::DriveAndPathFromFullName(const TDesC& aFullName)
   1.108 -	{ 	return BaflUtils::DriveAndPathFromFullName(aFullName);	}
   1.109 -
   1.110 -/** Gets the root folder for the specified drive.
   1.111 -
   1.112 -@param aDriveLetter The drive letter, C for example. 
   1.113 -@return The root folder for the drive, C:\ for example. */
   1.114 -inline TFileName EikFileUtils::RootFolderPath(const TBuf<1> aDriveLetter)
   1.115 -	{	return BaflUtils::RootFolderPath(aDriveLetter);	}
   1.116 -
   1.117 -/** Abbreviates a file name.
   1.118 -
   1.119 -If aOriginalFileName is less than the maximum length of aAbbreviatedFileName, 
   1.120 -then the name is simply copied to aAbbreviatedFileName.
   1.121 -
   1.122 -If this is not the case, then the left-most characters of aOriginalFileName are 
   1.123 -copied to aAbbreviatedFileName, up to aAbbreviatedFileName's maximum length-1 and 
   1.124 -aAbbreviatedFileName's first character is set to be an ellipsis.
   1.125 -
   1.126 -For example, if c:\\home\\letters\\abcdef is the original file name and aAbbreviatedFileName 
   1.127 -allows only 7 characters, the abbreviated file name will be ...abcdef. 
   1.128 -This can be used to display a file or folder name in an error or progress 
   1.129 -dialog.
   1.130 -
   1.131 -@param aOriginalFileName Original file name. 
   1.132 -@param aAbbreviatedFileName On return, the abbreviated file name. */
   1.133 -inline void EikFileUtils::AbbreviateFileName(const TFileName& aOriginalFileName, TDes& aAbbreviatedFileName)
   1.134 -	{	BaflUtils::AbbreviateFileName(aOriginalFileName,aAbbreviatedFileName);	}
   1.135 -
   1.136 -/** Tests whether two UID types match.
   1.137 -
   1.138 -A match is made if each UID in aMatchUid is either identical to the corresponding 
   1.139 -one in aFileUid, or is KNullUid.
   1.140 -
   1.141 -@param aFileUid The UID type to match. 
   1.142 -@param aMatchUid The UID type to match against. 
   1.143 -@return ETrue if the UIDs match, EFalse if not. */
   1.144 -inline TBool EikFileUtils::UidTypeMatches(const TUidType& aFileUid, const TUidType& aMatchUid)
   1.145 -	{	return BaflUtils::UidTypeMatches(aFileUid,aMatchUid);	}
   1.146 -
   1.147 -/** Tests whether a specified file name can be parsed.
   1.148 -
   1.149 -@param aName The file name to parse.
   1.150 -@return KErrNone if the filename can be parsed, otherwise one 
   1.151 -of the system-wide error codes. 
   1.152 -@see TParse */
   1.153 -inline TInt EikFileUtils::Parse(const TDesC& aName)
   1.154 -	{	return BaflUtils::Parse(aName);	}
   1.155 -
   1.156 -/** Copies the specified file.
   1.157 -
   1.158 -Notes:
   1.159 -
   1.160 -- files can be copied across drives
   1.161 -
   1.162 -- open files can be copied only if they have been opened using the EFileShareReadersOnly 
   1.163 -file share mode
   1.164 -
   1.165 -- the source file's attributes are preserved in the target file
   1.166 -
   1.167 -@param aSourceFullName Path indicating the file(s) to be copied. Any path 
   1.168 -components which are not specified here will be taken from the session path. 
   1.169 -@param aTargetFullName Path indicating the directory into which the file(s) 
   1.170 -are to be copied. 
   1.171 -@param aSwitch Optional switch to allow overwriting files with the same name 
   1.172 -in the target directory, or recursion. By default, this function operates with 
   1.173 -overwriting and non-recursively. Switch options are defined using the enum TSwitch. 
   1.174 -If recursive operation is set, any intermediate directories are created. If no overwriting 
   1.175 -is set, any files with the same name are not overwritten, and an error is returned 
   1.176 -for that file.
   1.177 -@return KErrNone if the copy is successful, otherwise another of the system-wide 
   1.178 -error codes. */
   1.179 -inline TInt EikFileUtils::CopyFile(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch)
   1.180 -	{	return BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(),aSourceFullName,aTargetFullName,aSwitch);	}
   1.181 -
   1.182 -/** Renames one or more files or directories. 
   1.183 -
   1.184 -This can also be used to move files by specifying different destination and 
   1.185 -source directories, but note that the destination and source directories must be 
   1.186 -on the same drive.
   1.187 -
   1.188 -If moving files, you can set aSwitch so that any files with the same name 
   1.189 -that exist in the target directory are overwritten. If aSwitch is set for 
   1.190 -no overwriting, any files with the same name are not overwritten, and an error 
   1.191 -(KErrAlreadyExists) is returned for that file.
   1.192 -
   1.193 -This function can only operate non-recursively, so that only the matching 
   1.194 -files located in the single directory specified by aOldFullName may be renamed.
   1.195 -
   1.196 -Read-only, system and hidden files may be renamed or moved, and the source 
   1.197 -file's attributes are preserved in the target file, but attempting to rename 
   1.198 -or move an open file will return an error for that file.
   1.199 -
   1.200 -@param aOldFullName Path specifying the file or directory to be renamed. 
   1.201 -@param aNewFullName Path specifying the new name for the file or directory. 
   1.202 -Any directories specified in this path which do not exist will be created. 
   1.203 -@param aSwitch Optional, sets whether files are overwritten on the target. 
   1.204 -@return KErrNone if successful otherwise another of the system-wide error codes. */
   1.205 -inline TInt EikFileUtils::RenameFile(const TDesC& aOldFullName, const TDesC& aNewFullName, TUint aSwitch)
   1.206 -	{	return BaflUtils::RenameFile(CEikonEnv::Static()->FsSession(),aOldFullName,aNewFullName,aSwitch);	}
   1.207 -
   1.208 -/** Deletes one or more files.
   1.209 -
   1.210 -This function may operate recursively or non-recursively. When operating non-recursively, 
   1.211 -only the matching files located in the directory specified in aSourceFullName 
   1.212 -are affected. When operating recursively, all matching files in the directory 
   1.213 -hierarchy below the directory specified in aSourceFullName are deleted.
   1.214 -
   1.215 -Attempting to delete read-only or open files returns an error.
   1.216 -
   1.217 -@param aSourceFullName Path indicating the file(s) to be deleted. This can 
   1.218 -either be a full path, or a path relative to the session path. Use wildcards 
   1.219 -to specify more than one file. 
   1.220 -@param aSwitch Determines whether this function operates recursively. By default, 
   1.221 -this function operates non-recursively. 
   1.222 -@return KErrNone if aSourceFullName is successfully deleted, otherwise another 
   1.223 -of the system-wide error codes. */
   1.224 -inline TInt EikFileUtils::DeleteFile(const TDesC& aSourceFullName, TUint aSwitch)
   1.225 -	{	return BaflUtils::DeleteFile(CEikonEnv::Static()->FsSession(), aSourceFullName,aSwitch);	}
   1.226 -
   1.227 -/** Tests whether a file specification is a valid folder name.
   1.228 -
   1.229 -@param aFullName The string to check. 
   1.230 -@param aIsFolder True if aFullName is a valid folder name, otherwise false.
   1.231 -@return KErrNone if successful, otherwise another of the system-wide error codes 
   1.232 -(probably because aFullName cannot be parsed). */
   1.233 -inline TInt EikFileUtils::CheckWhetherFullNameRefersToFolder(const TDesC& aFullName, TBool& aIsFolder)
   1.234 -	{	return BaflUtils::CheckWhetherFullNameRefersToFolder(aFullName,aIsFolder);	}
   1.235 -
   1.236 -/** Gets the folder name if the specified item is a valid folder name, otherwise gets the file name.
   1.237 -
   1.238 -@param aFullName Item to parse. 
   1.239 -@param aMostSignificantPart On return, the folder or file name.
   1.240 -@return KErrNone if successful otherwise another of the system-wide error codes. */
   1.241 -inline TInt EikFileUtils::MostSignificantPartOfFullName(const TDesC& aFullName, TFileName& aMostSignificantPart)
   1.242 -	{	return BaflUtils::MostSignificantPartOfFullName(aFullName,aMostSignificantPart);	}
   1.243 -
   1.244 -/** Tests whether the specified folder exists and can be opened.
   1.245 -
   1.246 -This returns an error code if the folder does not exist: see also FolderExists() 
   1.247 -which returns a boolean value.
   1.248 -
   1.249 -@param aFolderName The folder's name and path. 
   1.250 -@return KErrNone if aFolderName exists, otherwise another of the system-wide 
   1.251 -error codes. */
   1.252 -inline TInt EikFileUtils::CheckFolder(const TDesC& aFolderName)
   1.253 -	{	return BaflUtils::CheckFolder(CEikonEnv::Static()->FsSession(),aFolderName);	}
   1.254 -
   1.255 -/** Tests whether the specified drive is read-only.
   1.256 -
   1.257 -@param aFullName File name, including drive. 
   1.258 -@param aIsReadOnly On return, true if the drive is read-only, otherwise false. 
   1.259 -@return KErrNone if successful otherwise another of the system-wide error codes. */
   1.260 -inline TInt EikFileUtils::DiskIsReadOnly(const TDesC& aFullName, TBool& aIsReadOnly)	
   1.261 -	{	return BaflUtils::DiskIsReadOnly(CEikonEnv::Static()->FsSession(),aFullName,aIsReadOnly);	}
   1.262 -
   1.263 -/** Gets a list of all drives present on the system.
   1.264 -
   1.265 -The file server is interrogated for a list of the drive letters for all available 
   1.266 -drives. The drive letter that corresponds to aDriveNumber is added to the list 
   1.267 -regardless of whether it is present, or is corrupt. Also, the C: drive and the 
   1.268 -primary partitions on removable media slots are forced onto the list, even if 
   1.269 -corrupt or not present.
   1.270 -
   1.271 -@param aFs A connected session with the file server. 
   1.272 -@param aArray On return, contains the drive letters that correspond to the available 
   1.273 -drives. The drive letters are uppercase and are in alphabetical order. 
   1.274 -@param aIncludeRom ETrue if the ROM is included as a drive, EFalse otherwise. 
   1.275 -@param aDriveNumber The drive to force into the list, e.g. the drive in the default 
   1.276 -path. */
   1.277 -inline void EikFileUtils::UpdateDiskListL(const RFs& aFs,CDesCArray& aArray,TBool aIncludeRom,TDriveNumber aDriveNumber)
   1.278 -	{	BaflUtils::UpdateDiskListL(aFs,aArray,aIncludeRom,aDriveNumber);	}
   1.279 -
   1.280 -/** Removes the System directory from a list of directory entries.
   1.281 -
   1.282 -@param aDir Array of directory entries. */
   1.283 -inline void EikFileUtils::RemoveSystemDirectory(CDir& aDir)
   1.284 -	{	BaflUtils::RemoveSystemDirectory(aDir);	}
   1.285 -
   1.286 -/** Tests whether the specified drive corresponds to the primary partition 
   1.287 -in a removable media slot.
   1.288 -
   1.289 -Note that the function assumes that the D: drive corresponds to the primary 
   1.290 -partition on socket 0, and that the E: drive corresponds to the primary 
   1.291 -partition on socket 1 (a socket is a slot for removable media). This mapping 
   1.292 -may not always be the case because it is set up in the variant layer of Symbian 
   1.293 -OS. 
   1.294 -
   1.295 -@param aDriveUnit The drive to check. 
   1.296 -@return True if the drive is the primary partition in a removable media 
   1.297 -slot. True is also returned if the drive is C:. False is returned otherwise. */
   1.298 -inline TBool EikFileUtils::IsFirstDriveForSocket(TDriveUnit aDriveUnit)
   1.299 -	{	return BaflUtils::IsFirstDriveForSocket(aDriveUnit);	}
   1.300 -
   1.301 -/** Sorts files by UID.
   1.302 -
   1.303 -The caller supplies a table which specifies the order in which files are to be sorted. 
   1.304 -The files whose UID3 is the first UID in the table appear first. The files whose UID3 
   1.305 -is the UID specified second appear next, and so on. Files whose UID3 is not specified 
   1.306 -in the table, and directories, appear at the end of the list, with directories preceding 
   1.307 -the files, and with files sorted in ascending order of UID3.
   1.308 -
   1.309 -This function is used for customising how lists of application files are sorted.
   1.310 -
   1.311 -@param aDir The array of files and directories to sort. 
   1.312 -@param aTable A sort order table containing the UIDs to use in the sort. 
   1.313 -@return KErrNone if successful otherwise another of the system-wide error codes. */
   1.314 -inline TInt EikFileUtils::SortByTable(CDir& aDir,CBaflFileSortTable* aTable)
   1.315 -	{	return BaflUtils::SortByTable(aDir,aTable);	}
   1.316 -
   1.317 -
   1.318 -#endif	// __EIKFUTIL_H__