Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfsrv\cl_cli.cpp
27 EFSRV_EXPORT_C TBool RFs::IsValidDrive(TInt aDrive)
29 Tests whether the specified drive number is valid.
31 A valid drive number is any number between 0 and (KMaxDrives-1) inclusive,
32 or the specific value KDefaultDrive (implying the session default drive).
34 @param aDrive The drive number.
36 @return True if the drive is valid; false if not.
42 return((aDrive>=0 && aDrive<KMaxDrives) || aDrive==KDefaultDrive);
48 EFSRV_EXPORT_C TInt RFs::CharToDrive(TChar aChar,TInt& aDrive)
50 Maps a drive character to a drive number.
52 The drive character must be in the range A to Z or a to z. For example, drive A (or a)
53 corresponds to zero, drive B (or b) corresponds to 1 etc. For the drive number
54 enumeration, see TDriveNumber.
56 @param aChar The drive character.
57 @param aDrive On return, contains the drive number.
59 @return KErrNone, if successful;
60 KErrArgument, if the drive character is not in the range A to Z or a to z.
67 if (aChar>='A' && aChar<='Z')
69 aDrive=(TInt)aChar-'A';
78 EFSRV_EXPORT_C TInt RFs::DriveToChar(TInt aDrive,TChar& aChar)
80 Maps a drive number to the corresponding character.
82 The drive number must be in the range 0 to (KMaxDrives-1). For example, drive
83 number zero (EDriveA) corresponds to drive A, one (EDriveB)
84 corresponds to drive B. For the drive number enumeration, see TDriveNumber.
86 The drive number can also be KDefaultDrive, implying the default drive. In this
87 case the current drive is taken and converted.
89 @param aDrive The drive number.
90 @param aChar On return, contains the drive character.
92 @return KErrNone, if successful;
93 KErrArgument, if the drive number is invalid;
94 otherwise one of the other system-wide error codes.
98 if (aDrive==KDefaultDrive)
100 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsDriveToChar, MODULEUID, aDrive);
106 r=fs.SessionPath(path);
111 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsDriveToCharReturn, MODULEUID, KErrNone, aChar);
114 if (!IsValidDrive(aDrive))
115 return(KErrArgument);
123 EFSRV_EXPORT_C TBool RFs::IsRomAddress(TAny *aPtr)
125 Tests whether the specified address is in ROM.
127 @param aPtr The address.
129 @return True, if the address is in ROM; false, if not.
132 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsIsRomAddress, MODULEUID, aPtr);
135 TInt r=User::IsRomAddress(res,aPtr); // Only returns error on WINS
139 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsIsRomAddressReturn, MODULEUID, res);
146 Obtain the system drive number.
148 The System Drive is a defined drive on the device which is:
150 - Internal: Always available and not removable from the device
151 - Non-Volatile (e.g. Flash memory, battery-backed RAM)
152 - Only Accessible via Rfs (e.g. not available via USB mass storage)
154 The System drive is utilised as:
155 - Storage for Persistent settings from system and application software
156 - Storage for Localisation resources
157 - A Default Drive for user data
158 - A Target Drive for Software installations
160 It the system drive is not set previously (see RFs::SetSystemDrive) EDriveC is returned by default.
162 @see RFs::GetSystemDriveChar
163 @see RFs::SetSystemDrive
165 @return TDriveNumber contains the drive number of the system drive.
167 EFSRV_EXPORT_C TDriveNumber RFs::GetSystemDrive()
169 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsGetSystemDrive, MODULEUID);
171 TInt err = RProperty::Get(TSecureId(KFileServerUidValue), KSystemDriveKey, drive);
174 if((drive>=EDriveA) && (drive<=EDriveZ))
176 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsGetSystemDriveReturn, MODULEUID, drive);
177 return static_cast<TDriveNumber>(drive);
181 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsGetSystemDriveReturn, MODULEUID, EDriveC);
188 This is a wrapper around GetSystemDrive() function. It returns the character corresponding to the system drive.
190 @parameter aDriveChar On return, contains the system drive character
191 @return KErrNone if successful, otherwise one of the other system-wide error codes
192 @see RFs::GetSystemDrive
194 EFSRV_EXPORT_C TChar RFs::GetSystemDriveChar()
196 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsGetSystemDriveChar, MODULEUID);
198 TInt r = 'A' + GetSystemDrive();
200 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsGetSystemDriveCharReturn, MODULEUID, r);
207 Set a specified drive as a "System Drive", see RFs::GetSystemDrive().
208 The "System Drive" can be set only once, any subsequent calls will result in the error 'KErrAlreadyExists'.
210 The media type for the system drive shall be one of the: EMediaHardDisk, EMediaFlash, EMediaNANDFlash, EMediaRam
211 Required drive attributes: KDriveAttLocal, KDriveAttInternal
212 Prohibited drive attributes: KDriveAttRom,KDriveAttRedirected,KDriveAttSubsted,KDriveAttRemovable
214 @param aSystemDrive specifies the drive number to be set as System Drive
215 @return KErrNone if successful, otherwise one of the other system-wide error codes
218 EFSRV_EXPORT_C TInt RFs::SetSystemDrive(TDriveNumber aSystemDrive)
220 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsSetSystemDrive, MODULEUID, Handle(), aSystemDrive);
221 TInt r = SendReceive(EFsSetSystemDrive, TIpcArgs(aSystemDrive));
223 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetSystemDriveReturn, MODULEUID, r);
229 EFSRV_EXPORT_C TInt RFs::Connect(TInt aMessageSlots)
231 Connects a client to the file server.
233 To end the file server session, use Close().
235 @param aMessageSlots The number of message slots required. The default value of
236 KFileServerDefaultMessageSlots indicates that message
237 slots will be acquired dynamically from the system
238 wide pool. Override this value with a fixed number, if
239 a fixed number of slots are to be allocated to the session.
240 If overriding, note that the number of message slots
241 represents the number of operations, such as reads
242 and writes, that can be outstanding at once;
243 always remember to provide a spare slot for
244 the cancel operation.
246 @return KErrNone, if successful, otherwise one of the other system-wide
250 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsConnect, MODULEUID, aMessageSlots);
251 _LIT(KFileServerName,"!FileServer");
252 TInt r = CreateSession(KFileServerName,Version(),aMessageSlots);
254 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFsConnectReturn, MODULEUID, r, Handle());
261 EFSRV_EXPORT_C TInt RFs::SetSessionToPrivate(TInt aDrive)
263 Sets the session path to point to the private path on the specified drive.
265 The private directory does not need to exist at this point.
267 The private path for a process has the form: \\Private\\13579BDF\\
268 where 13579BDF is the identity of the process.
270 @param aDrive The drive for which information is requested.
271 Specify a drive in the range EDriveA to EDriveZ for drives
274 @return KErrNone, if successful, otherwise one of the other system-wide
278 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsSetSessionToPrivate, MODULEUID, Handle(), aDrive);
279 TInt r = SendReceive(EFsSessionToPrivate,TIpcArgs(aDrive));
281 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetSessionToPrivateReturn, MODULEUID, r);
287 EFSRV_EXPORT_C TInt RFs::PrivatePath(TDes& aPath)
289 Creates the text defining the private path for a process.
291 The private path for a process has the form: \\Private\\13579BDF\\
292 where 13579BDF is the identity of the process.
294 @param aPath On successful return, contains the private path for a process.
297 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsPrivatePath, MODULEUID, Handle());
298 TInt r = SendReceive(EFsPrivatePath,TIpcArgs(&aPath));
300 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsPrivatePathReturn, MODULEUID, r, aPath);
306 EFSRV_EXPORT_C TInt RFs::CreatePrivatePath(TInt aDrive)
308 Creates the private path for a process on the specified drive.
310 The private path for a process has the form: \\Private\\13579BDF\\
311 where 13579BDF is the identity of the process.
313 @param aDrive The drive for which the private path is to be created.
314 Specify a drive in the range EDriveA to EDriveZ for drives
317 @return KErrNone, if successful, otherwise one of the other system-wide
321 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsCreatePrivatePath, MODULEUID, Handle(), aDrive);
322 TInt r = SendReceive(EFsCreatePrivatePath,TIpcArgs(aDrive));
324 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsCreatePrivatePathReturn, MODULEUID, r);
331 EFSRV_EXPORT_C TVersion RFs::Version() const
333 Gets the client side version number.
335 @return The client side version number.
338 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsVersion, MODULEUID, Handle());
340 TVersion r = TVersion(KF32MajorVersionNumber,KF32MinorVersionNumber,KF32BuildVersionNumber);
342 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFsVersionReturn, MODULEUID, r.iMajor, r.iMinor, r.iBuild);
349 EFSRV_EXPORT_C TInt RFs::AddFileSystem(const TDesC& aFileName) const
351 Adds a file system to the file server.
353 After calling this function, use MountFileSystem() to mount the file system
356 @param aFileName The name of the file system .FSY to install. Its full path can
359 @return KErrNone, if successful, otherwise one of the other system-wide
362 @capability DiskAdmin
364 @see RFs::MountFileSystem
367 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsAddFileSystem, MODULEUID, Handle(), aFileName);
369 TInt r = loader.Connect();
372 r = loader.SendReceive(ELoadFileSystem, TIpcArgs(0, &aFileName, 0));
376 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsAddFileSystemReturn, MODULEUID, r);
383 EFSRV_EXPORT_C TInt RFs::RemoveFileSystem(const TDesC& aFileSystemName) const
385 Removes the specified file system.
387 @param aFileSystemName The fullname of the file system, as returned from
388 a call to FileSystemName(), to be removed.
390 @return KErrNone, if successful;
391 KErrNotFound, if aFileSystemName is not found;
392 otrherwise one of the other system-wide error codes.
394 @capability DiskAdmin
398 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsRemoveFileSystem, MODULEUID, Handle(), aFileSystemName);
399 TInt r = SendReceive(EFsRemoveFileSystem,TIpcArgs(&aFileSystemName));
401 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsRemoveFileSystemReturn, MODULEUID, r);
408 EFSRV_EXPORT_C TInt RFs::MountFileSystem(const TDesC& aFileSystemName,TInt aDrive) const
410 Mounts a file system on a drive.
412 The file system must first have been added to the file server using AddFileSystem().
413 The drive is mounted as asynchronous, i.e operations on it don't block the file server and other drives;
415 @param aFileSystemName The fullname of the file system, as returned from a call to FileSystemName().
416 @param aDrive The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.
418 @return KErrNone if successful, otherwise one of the other system-wide error codes.
420 @capability DiskAdmin
422 @see RFs::AddFileSystem
423 @see RFs::FileSystemName
426 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem1, MODULEUID, Handle(), aFileSystemName, aDrive);
427 TInt r = SendReceive(EFsMountFileSystem,TIpcArgs(&aFileSystemName,aDrive,NULL,EFalse));
429 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem1Return, MODULEUID, r);
437 EFSRV_EXPORT_C TInt RFs::MountFileSystem(const TDesC& aFileSystemName,TInt aDrive, TBool aIsSync) const
439 Mounts a file system on a specified drive.
441 The file system must first have been added to the file server using AddFileSystem().
442 Depending on the aIsSync parameter, the drive can be mounted as synchronous or asynchronous.
444 Asynchronous drive has its own processing thread, i.e operations on it don't block the file server and other drives;
445 Synchronous drives' requests are being processed by the main file server thread and there is a possibility to block it along with
446 all operations on other drives. Mounting a drive as synch. makes a sense if the operations on such drive are very fast e.g. this is an
447 internal RAM or ROFS drive.
449 @param aFileSystemName The fullname of the file system, as returned from a call to FileSystemName().
450 @param aDrive The drive number on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.
452 @param aIsSync if ETrue the drive will be mounted as synchronous one;
453 if EFalse the drive will be mounted as Asynchronous.
455 @return KErrNone if successful, otherwise one of the other system-wide error codes.
456 @capability DiskAdmin
458 @see RFs::AddFileSystem
459 @see RFs::FileSystemName
462 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem2, MODULEUID, Handle(), aFileSystemName, aDrive, aIsSync);
464 TInt r = SendReceive(EFsMountFileSystem,TIpcArgs(&aFileSystemName,aDrive,NULL,aIsSync));
466 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem2Return, MODULEUID, r);
473 EFSRV_EXPORT_C TInt RFs::MountFileSystem(const TDesC& aFileSystemName,const TDesC& aExtensionName,TInt aDrive)
475 Mounts a file system on a drive, and the specified extension.
477 The file system must first have been added to the file server using AddFileSystem().
478 The drive is mounted as asynchronous, i.e operations on it don't block the file server and other drives;
480 @param aFileSystemName The fullname of the file system, as returned from a call to FileSystemName().
481 @param aExtensionName The filename of the extension.
482 @param aDrive The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.
484 @return KErrNone if successful, otherwise one of the other system-wide error codes.
486 @capability DiskAdmin
488 @see RFs::AddFileSystem
489 @see RFs::FileSystemName
492 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem3, MODULEUID, Handle(), aFileSystemName, aExtensionName, aDrive);
494 TInt r = SendReceive(EFsMountFileSystem,TIpcArgs(&aFileSystemName,aDrive,&aExtensionName,EFalse));
496 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem3Return, MODULEUID, r);
503 EFSRV_EXPORT_C TInt RFs::MountFileSystem(const TDesC& aFileSystemName,const TDesC& aExtensionName,TInt aDrive, TBool aIsSync)
505 Mounts a file system on a drive, and the specified extension.
507 The file system must first have been added to the file server using AddFileSystem().
509 Depending on the aIsSync parameter, the drive can be mounted as synchronous or asynchronous.
511 Asynchronous drive has its own processing thread, i.e operations on it don't block the file server and other drives;
512 Synchronous drives' requests are being processed by the main file server thread and there is a possibility to block it along with
513 all operations on other drives. Mounting a drive as synch. makes sense if the operations on such drive are very fast e.g. this is an
514 internal RAM or ROFS drive.
516 @param aFileSystemName The fullname of the file system, as returned from a call to FileSystemName().
517 @param aExtensionName The filename of the extension.
518 @param aDrive The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.
520 @param aIsSync if ETrue the drive will be mounted as synchronous one;
521 if EFalse the drive will be mounted as Asynchronous.
523 @return KErrNone if successful, otherwise one of the other system-wide error codes.
525 @capability DiskAdmin
527 @see RFs::AddFileSystem
528 @see RFs::FileSystemName
531 TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem4, MODULEUID, Handle(), aFileSystemName, aExtensionName, aDrive, aIsSync);
532 TInt r = SendReceive(EFsMountFileSystem,TIpcArgs(&aFileSystemName,aDrive,&aExtensionName,aIsSync));
534 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystem4Return, MODULEUID, r);
541 EFSRV_EXPORT_C TInt RFs::MountFileSystemAndScan(const TDesC& aFileSystemName,TInt aDrive,TBool& aIsMountSuccess) const
543 Mounts a file system on a drive, and performs a scan on that drive.
544 The file system must first have been added to the file server using AddFileSystem().
546 Note that the scan is done only if the mount is successful.
548 The drive is mounted as asynchronous, i.e operations on it don't block the file server and other drives;
550 @param aFileSystemName The fullname of the file system, as returned from a call to FileSystemName().
551 @param aDrive The drive on which the file system is to be mounted; this can be one of the values defined by TDriveNumber.
552 @param aIsMountSuccess On return, set to: ETrue, if the if the mount is successful, set to EFalse otherwise.
554 @return KErrNone if successful, otherwise one of the other system-wide error codes, reflecting the failure of the mount operation.
556 @capability DiskAdmin
558 @see RFs::TDriveNumber
559 @see RFs::AddFileSystem
560 @see RFs::FileSystemName
563 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystemAndScan1, MODULEUID, Handle(), aFileSystemName, aDrive);
564 aIsMountSuccess=EFalse;
565 TPckg<TInt> pckg(aIsMountSuccess);
566 TInt r = SendReceive(EFsMountFileSystemScan,TIpcArgs(&aFileSystemName,aDrive,NULL,&pckg));
568 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystemAndScan1Return, MODULEUID, r, aIsMountSuccess);
572 EFSRV_EXPORT_C TInt RFs::MountFileSystemAndScan(const TDesC& aFileSystemName,const TDesC& aExtensionName,TInt aDrive,TBool& aIsMountSuccess) const
574 Mounts a file system on a drive, and the specified extension and performs a scan on that drive.
576 The file system must first have been added to the file server,
577 using AddFileSystem().
579 Note that the scan is done only if the mount is successful.
581 The operation is asynchronous, i.e other concurrent file server operations can continue.
583 @param aFileSystemName The fullname of the file system, as returned from
584 a call to FileSystemName().
585 @param aExtensionName The filename of the extension.
586 @param aDrive The drive on which the file system is to be mounted;
587 this can be one of the values defined by TDriveNumber.
588 @param aIsMountSuccess On return, set to: ETrue, if the if the mount
589 is successful, set to EFalse otherwise.
591 @return KErrNone if successful, otherwise one of the other system-wide
592 error codes, reflecting the failure of the mount operation.
594 @capability DiskAdmin
596 @see RFs::TDriveNumber
597 @see RFs::AddFileSystem
598 @see RFs::FileSystemName
601 TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystemAndScan2, MODULEUID,
602 Handle(), aFileSystemName, aExtensionName, aDrive, aIsMountSuccess);
604 aIsMountSuccess=EFalse;
605 TPckg<TInt> pckg(aIsMountSuccess);
606 TInt r = SendReceive(EFsMountFileSystemScan,TIpcArgs(&aFileSystemName,aDrive,&aExtensionName,&pckg));
608 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFsMountFileSystemAndScan2Return, MODULEUID, r, aIsMountSuccess);
612 EFSRV_EXPORT_C TInt RFs::DismountFileSystem(const TDesC& aFileSystemName,TInt aDrive) const
614 Dismounts the file system from the specified drive.
616 @param aFileSystemName The fullname of the file system, as returned from
617 a call to FileSystemName().
618 @param aDrive The drive from which the file system is to be dismounted.
620 @return KErrNone, if successful;
621 KErrNotFound, if aFileSystemName is not found;
622 KErrNotReady, if the drive does not have a file system mounted on it;
623 KErrInUse, if the drive has a resource open on it;
624 KErrAccessDenied, if there is an attempt to dismount a ROM file system,
625 a substituted drive, or the drive which is the default drive;
626 KErrArgument, if the specified drive value is outsdide of the valid range.
627 KErrPermissionDenied, if the client does not have the necessary capabilities
628 to dismount the file system.
630 @capability DiskAdmin
632 @see RFs::FileSystemName
635 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsDismountFileSystem, MODULEUID, Handle(), aFileSystemName, aDrive);
636 TInt r = SendReceive(EFsDismountFileSystem,TIpcArgs(&aFileSystemName,aDrive));
638 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsDismountFileSystemReturn, MODULEUID, r);
646 Gets the name of the file system mounted on the specified drive.
647 The function can be called before calling DismountFileSystem().
649 @param aName On successful return, contains the name of the file system.
650 @param aDrive The drive for which the file system name is required.
652 Note that the file system name, returned in the aName descriptor shall be threated as case-insensitive string. I.e.
653 "fileSystem" and "FILESYSTEM" mean absolutely the same. Therefore, case-insensitive string methods (like TDesC::FindF(), TDesC::CompareF())
654 shall be used to deal with the names.
656 @return KErrNone, if successful;
657 KErrNotFound if aFileSystemName is not found, or the drive does not have a file system mounted on it;
658 KErrArgument, if the drive value is outside the valid range, i.e. zero to KMaxDrives-1 inclusive.
660 @see RFs::DismountFileSystem
662 EFSRV_EXPORT_C TInt RFs::FileSystemName(TDes& aName,TInt aDrive) const
664 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemName, MODULEUID, Handle(), aDrive);
666 //-- ipc argument "-1" here is to indicate legacy FileSystemName() API
667 TInt r = SendReceive(EFsFileSystemName,TIpcArgs(&aName, aDrive, -1));
669 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemNameReturn, MODULEUID, r, aName);
675 Get one of the supported file system names on a specified drive. This API can be used for enumerating
676 file systems that can be recognised and mounted automatically, without user's interaction.
677 If the automatic recognition and mountng some known file systems is supported on the specified drive, there
678 shall be at least 2 names in the list. For example "FAT" and "exFAT".
679 If "automatic file system recognising" feature is not supported, the list will consist of just one name, and
680 this will be the name returned by RFs::FileSystemName() API.
682 Note that the file system name, returned in the aName descriptor shall be threated as case-insensitive string. I.e.
683 "fileSystem" and "FILESYSTEM" mean absolutely the same. Therefore, case-insensitive string methods (like TDesC::FindF(), TDesC::CompareF())
684 shall be used to deal with the names.
686 @param aName On successful return, contains the name of the file system that correspond to the aFsEnumerator value.
687 m@param aDrive The drive number
688 @param aFsEnumerator The supported file system enumerator. can be:
689 KRootFileSystem a special value; in this case the returned name will be the same as obtained by FileSystemName()
690 0,1,2... integer values specifying the sequential number of supported filesystem. See the return error code.
692 @return KErrNone success, aName contains a valid name for the supported file system number "aFsEnumerator" on this drive.
693 KErrNotFound the end of the supported file names list; "aFsEnumerator-1" was the last correct value
694 KErrArgument incorrect arguments
697 @see FileSystemName()
700 EFSRV_EXPORT_C TInt RFs::SupportedFileSystemName(TDes& aName, TInt aDrive, TInt aFsEnumerator) const
702 if(aFsEnumerator < 0)
703 return KErrArgument; //-- see RFs::FileSystemName(). "-1" is a reserved value
705 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemName, MODULEUID, Handle(), aDrive);
707 TInt r = SendReceive(EFsFileSystemName,TIpcArgs(&aName, aDrive, aFsEnumerator));
709 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemNameReturn, MODULEUID, r, aName);
717 EFSRV_EXPORT_C TInt RFs::AddExtension(const TDesC& aFileName)
719 Loads the specified extension.
721 @param aFileName The file name of the extension
723 @return KErrNone, if successful; otherwise one of the other system wide error codes.
726 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsAddExtension, MODULEUID, Handle(), aFileName);
728 TInt r = loader.Connect();
731 r = loader.SendReceive(ELoadFSExtension, TIpcArgs(0, &aFileName, 0));
735 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsAddExtensionReturn, MODULEUID, r);
742 EFSRV_EXPORT_C TInt RFs::MountExtension(const TDesC& aExtensionName,TInt aDrive)
744 Mounts the the specified extension.
746 The extension must first have been loaded using AddExtension().
748 @param aExtensionName The fullname of the extension, as returned from
749 a call to ExtensionName().
750 @param aDrive The drive on which the extension is to be mounted;
752 @return KErrNone if successful;
753 KErrNotFound, if the extension cannot be found;
754 otherwise one of the other system-wide error codes.
756 @see RFs::ExtensionName
759 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsMountExtension, MODULEUID, Handle(), aExtensionName, aDrive);
760 TInt r = SendReceive(EFsMountExtension,TIpcArgs(&aExtensionName,aDrive));
762 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMountExtensionReturn, MODULEUID, r);
770 Dismounts the specified extension.
772 @param aExtensionName The fullname of the extension, as returned from a call to ExtensionName().
773 @param aDrive The drive this extension is to be dismounted from.
775 @return KErrNone if successful;
776 KErrNotFound if the extension cannot be found;
777 otherwise one of the other system-wide error codes.
779 @see RFs::ExtensionName
781 EFSRV_EXPORT_C TInt RFs::DismountExtension(const TDesC& aExtensionName,TInt aDrive)
783 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsDismountExtension, MODULEUID, Handle(), aExtensionName, aDrive);
784 TInt r = SendReceive(EFsDismountExtension,TIpcArgs(&aExtensionName,aDrive));
786 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsDismountExtensionReturn, MODULEUID, r);
791 EFSRV_EXPORT_C TInt RFs::RemoveExtension(const TDesC& aExtensionName)
793 Removes the specified extension.
795 @param aExtensionName The fullname of the extension, as returned from
796 a call to ExtensionName().
798 @return KErrNone, if successful;
799 KErrNotFound, if aExtensionName is not found;
800 otrherwise one of the other system-wide error codes.
803 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsRemoveExtension, MODULEUID, Handle(), aExtensionName);
804 TInt r = SendReceive(EFsRemoveExtension,TIpcArgs(&aExtensionName));
806 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsRemoveExtensionReturn, MODULEUID, r);
813 EFSRV_EXPORT_C TInt RFs::ExtensionName(TDes& aExtensionName,TInt aDrive,TInt aPos)
815 Gets the name of the extension on the specified drive at the specified position
816 in the extension hierarchy.
818 @param aExtensionName On successful return, contains the name of the extension.
819 @param aDrive The drive for which the extension name is required.
820 @param aPos The position of the extension in the extension hierarchy.
822 @return KErrNone, if successful;
823 KErrNotFound if the extension name is not found;
826 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsExtensionName, MODULEUID, Handle(), aExtensionName, aDrive, aPos);
827 TInt r = SendReceive(EFsExtensionName,TIpcArgs(&aExtensionName,aDrive,aPos));
829 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsExtensionNameReturn, MODULEUID, r);
836 EFSRV_EXPORT_C TInt RFs::RemountDrive(TInt aDrive,const TDesC8* aMountInfo,TUint aFlags)
838 Forces a remount of the specified drive.
840 @param aDrive The drive for which a remount is to be forced.
841 @param aMountInfo Information passed down to the media driver. The meaning of
842 this information depends on the media driver, for example,
843 keys for secure areas.
844 @param aFlags When the flag is set to
845 0x00000001 - Used to simulate ejecting and re-inserting the media.
846 0x80000000 - used to force the media driver for the specified logical
847 drive to be closed and reopened.
849 @return KErrNone if successful, otherwise one of
850 the other system wide error codes.
853 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFsRemountDrive, MODULEUID, Handle(), aDrive, aMountInfo, aFlags);
854 TInt r = SendReceive(EFsRemountDrive,TIpcArgs(aDrive,aMountInfo,aFlags));
856 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsRemountDriveReturn, MODULEUID, r);
862 EFSRV_EXPORT_C void RFs::NotifyChange(TNotifyType aType,TRequestStatus& aStat)
864 Requests a notification of change to files or directories.
866 Changes are notified either:
868 1. following any change in the file system
872 2. only following the addition or deletion of a directory entry, or after
873 a disk has been formatted or changed.
875 Such notification is useful for programs that maintain displays
876 of file lists which must be dynamically updated. The alternative is to do
877 no updating, or to perform periodic monitoring for change, which
880 This is an asynchronous request and, as such, results in precisely one signal
881 to the request status passed as a parameter. To avoid missing any change, this
882 request should be issued before the first file list is constructed. When
883 the request completes, a new request should be issued before the next file
884 list is constructed. When the file server session is
885 closed, this request is implicitly cancelled.
887 Call NotifyChangeCancel() to explicitly cancel a notification request.
889 @param aType Indicates the kind of change that should result in notification.
891 ENotifyEntry causes notification only when an entry is added or
892 deleted, or when a disk is formatted or changed;
893 ENotifyAll causes notification following any type of change, such
894 as when a file is written to, or when a file's attributes
896 @param aStat The request status.
897 This is set to KErrNone on completion, otherwise one of the other
898 system-wide error codes.
902 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChange1, MODULEUID, Handle(), aType, &aStat);
903 aStat=KRequestPending;
904 // for backward compatibility
905 TNotifyType type = (aType == 0 ? ENotifyEntry : aType);
906 RSessionBase::SendReceive(EFsNotifyChange, TIpcArgs(type,&aStat) , aStat );
907 //This call is to synchronise with the file server when this functions stack varibles can go out of scope
908 SendReceive(EFsSynchroniseDriveThread, TIpcArgs(-1));
910 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChange1Return, MODULEUID);
916 EFSRV_EXPORT_C void RFs::NotifyChange(TNotifyType aType,TRequestStatus& aStat,const TDesC& aPathName)
918 Requests a notification of change to files or directories, allowing
919 a directory/file path to be specified.
921 Changes are notified either:
923 1. following any change in the file system
927 2. only following the addition or deletion of a directory entry, or after
928 a disk has been formatted or changed.
930 Such notification is useful for programs that maintain displays
931 of file lists which must be dynamically updated. The alternative is to do
932 no updating, or to perform periodic monitoring for change, which
935 This is an asynchronous request and, as such, results in precisely one signal
936 to the request status passed as a parameter. To avoid missing any change, this
937 request should be issued before the first file list is constructed. When
938 the request completes, a new request should be issued before the next file
939 list is constructed. When the file server session is
940 closed, this request is implicitly cancelled.
942 Call NotifyChangeCancel() to explicitly cancel a notification request.
944 @param aType Indicates the kind of change that should result in
945 notification. For example:
946 ENotifyEntry causes notification only when an entry is added
947 or deleted, or when a disk is formatted or changed;
948 ENotifyAll causes notification following any type of change,
949 such as when a file is written to, or when a file's attributes
951 @param aStat The request status.
952 This is set to KErrNone on completion, otherwise one of
953 the other system-wide error codes.
954 @param aPathName The directory or file for which notification is required. By
955 specifying a drive as a wildcard, for example
956 "?:\\Resource\\apps\\", or
957 "*:\\Resource\\apps\\", a client can ask to be notified of changes
958 to a given directory on any drive.
959 As with all directory paths aPathName must be terminated with '\\',
960 Please refer to "Structure of paths and filenames" section in the
963 @capability Dependent If aName is /Sys then AllFiles capability is required.
964 @capability Dependent If aName begins with /Private and does not match this process' SID
965 then AllFiles capability is required.
969 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChange2, MODULEUID, Handle(), (TUint) aType, (TUint) &aStat, aPathName);
970 aStat=KRequestPending;
971 // for backward compatibility
972 TNotifyType type = (aType == 0 ? ENotifyEntry : aType);
973 RSessionBase::SendReceive(EFsNotifyChangeEx,TIpcArgs(type,&aPathName,&aStat),aStat);
974 //This call is to synchronise with the file server when this functions stack varibles can go out of scope
975 SendReceive(EFsSynchroniseDriveThread, TIpcArgs(-1));
977 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChange2Return, MODULEUID);
983 EFSRV_EXPORT_C void RFs::NotifyChangeCancel()
985 Cancels all outstanding requests for notification of change
986 to files or directories.
988 All outstanding requests complete with KErrCancel.
990 Note that this is a synchronous function.
994 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChangeCancel1, MODULEUID, Handle());
995 RSessionBase::SendReceive(EFsNotifyChangeCancel);
997 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChangeCancel1Return, MODULEUID);
1003 EFSRV_EXPORT_C void RFs::NotifyChangeCancel(TRequestStatus& aStat)
1005 Cancels the specific request for notification of change
1006 to files or directories.
1008 The outstanding request completes with KErrCancel.
1010 Note that this is an asynchronous function.
1012 @param aStat The request status object associated with the request
1013 to be cancelled. Note that the function does not change
1018 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChangeCancel2, MODULEUID, Handle(), &aStat);
1019 if (aStat==KRequestPending) // May be better to ASSERT this?
1020 SendReceive(EFsNotifyChangeCancelEx,TIpcArgs(&aStat));
1022 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyChangeCancel2Return, MODULEUID);
1028 EFSRV_EXPORT_C void RFs::NotifyDiskSpace(TInt64 aThreshold,TInt aDrive,TRequestStatus& aStat)
1030 Requests notification when the free disk space on the specified
1031 drive crosses the specified threshold value.
1033 The threshold is crossed if free disk space increases to a value above
1034 the threshold value or decreases to a value below the threshold value.
1036 This is an asynchronous request that completes if any of the
1037 following events occur:
1039 1. the threshold is crossed
1041 2. any drive is formatted
1043 3. there is a media change on any socket
1047 5. the scandrive utility is run on any drive
1049 5. the specified threshold value is outside its limits
1051 7. the outstanding request is cancelled.
1053 Note that free disk space notification is not supported for
1054 drives using remote file systems.
1056 @param aThreshold The threshold value. This must be greater than zero and less
1057 than the total size of the disk.
1058 @param aDrive The drive number. This is an explicit drive defined by one of
1059 the TDriveNumber enum values or the value
1060 KDefaultDrive. If KDefaultDrive is specified, then
1061 the drive monitored is the session path drive.
1062 @param aStat The request status object. On request completion, contains:
1063 KErrNone, if the threshold value is crossed, if any drive is
1064 formatted, if there is a media change on any socket, if there is a power up or
1065 if the scandrive utility is run on any drive;
1066 KErrCancel, if the outstanding request is cancelled by a call to
1067 NotifyDiskSpaceCancel();
1068 KErrArgument, if the threshold value is outside its limits.
1073 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpace, MODULEUID,
1074 Handle(), I64LOW(aThreshold),I64HIGH(aThreshold), aDrive,(TUint) &aStat);
1075 aStat=KRequestPending;
1076 TPtrC8 tBuf((TUint8*)&aThreshold,sizeof(TInt64));
1077 RSessionBase::SendReceive(EFsNotifyDiskSpace,TIpcArgs(&tBuf,aDrive,&aStat), aStat);
1078 //This call is to synchronise with the driver thread as corresponding cancel function (NotifyDiskSpaceCancel)
1079 //is synchronous, so it can complete before this notify request has even been added to TDiskSpaceQue.
1080 //This call guarantees that the notify request has been added to queue.
1081 SendReceive(EFsSynchroniseDriveThread, TIpcArgs(aDrive));
1084 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpaceReturn, MODULEUID);
1090 EFSRV_EXPORT_C void RFs::NotifyDiskSpaceCancel(TRequestStatus& aStat)
1092 Cancels a specific outstanding request for free disk space
1095 The outstanding request completes with KErrCancel.
1097 @param aStat The request status object identified with the original
1098 notification request.
1101 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpaceCancel1, MODULEUID, Handle(), &aStat);
1103 if(aStat==KRequestPending)
1104 SendReceive(EFsNotifyDiskSpaceCancel,TIpcArgs(&aStat));
1106 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpaceCancel1Return, MODULEUID);
1112 EFSRV_EXPORT_C void RFs::NotifyDiskSpaceCancel()
1114 Cancels all outstanding requests for free disk space
1117 Outstanding requests complete with KErrCancel.
1120 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpaceCancel2, MODULEUID, Handle());
1121 SendReceive(EFsNotifyDiskSpaceCancel,TIpcArgs(NULL));
1123 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDiskSpaceCancel2Return, MODULEUID);
1129 EFSRV_EXPORT_C TInt RFs::DriveList(TDriveList& aList) const
1131 Gets a list of the available (not remote and non hidden) drives.
1133 The drive list consists of an array of 26 bytes. Array index zero corresponds
1134 to drive A, index one equals B etc.
1136 Each byte with a non zero value signifies that the corresponding drive is available
1137 to the system. In the case of removable media, RFs::Drive should be used to determine
1138 whether the media is inserted or not.
1140 The local file system always reserves drive letters A through I.
1141 Drive letter Z is always used for the ROM which means that letters J through Y
1142 are available to be used by SetSubst() or for redirecting.
1144 @param aList On return, contains a list of drive attributes (only the first 8 bits) for the available non-remote and non-hidden drives.
1146 @return KErrNone, successful, otherwise one of the other system-wide error codes.
1149 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsDriveList1, MODULEUID, Handle());
1150 TInt r = SendReceive(EFsDriveList,TIpcArgs(&aList, KDriveAttExclude|KDriveAttRemote|KDriveAttHidden));
1152 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsDriveList1Return, MODULEUID, r);
1158 EFSRV_EXPORT_C TInt RFs::DriveList(TDriveList& aList, TUint aFlags) const
1160 Gets a list of the available drives that match a combination of drive attributes,specified in aFlags.
1161 This combination may include,exclude or exclusively specify the attributes that that drives to be returned
1164 The drive list consists of an array of 26 bytes. Array index zero corresponds
1165 to drive A, index one equals B etc.
1167 Each byte with a non zero value signifies that the corresponding drive is available
1168 to the system. In the case of removable media, RFs::Drive should be used to determine
1169 whether the media is inserted or not.
1171 The local file system always reserves drive letters A through I.
1172 Drive letter Z is always used for the ROM which means that letters J through Y
1173 are available to be used by SetSubst() or for redirecting.
1175 @param aList On return, contains a list of available drives that qualify aFlags.
1177 @param aFlags A combination of drive attributes that drives to be returned must qualify.
1179 @return KErrNone, successful, otherwise one of the other system-wide error codes;
1180 KErrArgument, If aFlags contains an invalid attribute combination.
1183 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsDriveList2, MODULEUID, Handle(), aFlags);
1184 TInt r = SendReceive(EFsDriveList,TIpcArgs(&aList,aFlags));
1186 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsDriveList2Return, MODULEUID, r);
1193 EFSRV_EXPORT_C TInt RFs::Drive(TDriveInfo& anInfo,TInt aDrive) const
1195 Gets information about a drive and the medium mounted on it.
1197 Note that Volume() can also be used to give information about the drive and
1198 the volume mounted on it. These two functions are separate because, while
1199 the characteristics of a drive cannot change, those of a
1200 volume can, by mounting different media, reformatting etc.
1202 @param anInfo On return, contains information describing the drive
1203 and the medium mounted on it. The value of TDriveInfo::iType
1204 shows whether the drive contains media.
1205 @param aDrive The drive for which information is requested.
1206 Specify KDefaultDrive for the session default drive.
1207 Specify a drive in the range EDriveA to EDriveZ for drives
1208 A to Z respectively.
1210 @return KErrNone, if successful, otherwise one of the other
1211 system-wide error codes.
1216 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsDrive, MODULEUID, Handle(), aDrive);
1218 TPckg<TDriveInfo> m(anInfo);
1219 TInt r = SendReceive(EFsDrive,TIpcArgs(&m,aDrive));
1221 TRACERET4(UTF::EBorder, UTraceModuleEfsrv::EFsDriveReturn, MODULEUID, r, anInfo.iDriveAtt, anInfo.iMediaAtt, anInfo.iType);
1228 EFSRV_EXPORT_C TInt RFs::Volume(TVolumeInfo& aVol,TInt aDrive) const
1230 Gets volume information for a formatted device.
1232 This function provides additional information to that given by Drive(),
1233 including the volume label, if set, and the amount of free space on the
1236 Note, use Drive() to get information about the drive without reference to
1237 a volume. These two functions are separate because, while the characteristics
1238 of a drive cannot change, those of a volume can, by mounting different media,
1239 reformatting etc. A volume may not even be present if the media is removable.
1241 @param aVol On return, contains the volume information.
1242 @param aDrive The drive which contains the media for which volume information is to be displayed.
1243 Specify a drive in the range EDriveA to EDriveZ for drives A to Z respectively.
1244 The default drive is the session default drive KDefaultDrive.
1246 @return KErrNone, if successful;
1247 KErrNotReady, if the drive contains no media;
1248 otherwise one of the other system-wide error codes.
1253 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsVolume1, MODULEUID, Handle(), aDrive);
1254 TPckg<TVolumeInfo> v(aVol);
1255 TInt r = SendReceive(EFsVolume,TIpcArgs(&v,aDrive,NULL));
1257 TRACE7(UTF::EBorder, UTraceModuleEfsrv::EFsVolume1Return, MODULEUID,
1258 r, aVol.iUniqueID, I64LOW(aVol.iSize), I64HIGH(aVol.iSize),
1259 I64LOW(aVol.iFree), I64HIGH(aVol.iFree), aVol.iFileCacheFlags);
1264 Gets volume information for a formatted device asynchronously.
1265 @see TInt RFs::Volume(TVolumeInfo& aVol,TInt aDrive) for the synchronous version.
1267 "Asynchronously" corresponds to the amount of free space on the volume in TVolumeInfo::iFree.
1268 I.e. this function returns the _current_ amount of free space on the volume, which can be changing due to some
1269 filesystems' activities. For example, some filesystems can be performing free space calculations in the background.
1270 Comparing to the RFs::Volume(TVolumeInfo& aVol,TInt aDrive), this method doesn't block the client until background filesystem
1271 activity finishes, which can be useful in some situations.
1273 @param aVol On return, contains the volume information with the _current_ value in the TVolumeInfo::iFree.
1274 @param aDrive Drive number to query. Specify a drive in the range EDriveA to EDriveZ for drives A to Z respectively.
1275 @param aStat request status. At present is used just for indication of the asynchronous version and gets immediately completed, so there is no reason to analyse its value.
1280 EFSRV_EXPORT_C void RFs::Volume(TVolumeInfo& aVol,TInt aDrive, TRequestStatus& aStat) const
1282 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsVolume2, MODULEUID, Handle(), aDrive, &aStat);
1283 TPckg<TVolumeInfo> v(aVol);
1284 aStat=KRequestPending;
1285 RSessionBase::SendReceive(EFsVolume,TIpcArgs(&v,aDrive,&aStat), aStat);
1287 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsVolume2Return, MODULEUID);
1291 EFSRV_EXPORT_C TInt RFs::SetVolumeLabel(const TDesC& aName,TInt aDrive)
1293 Sets the label for a volume.
1295 Note that similar to file names, volume labels can be set with unicode characters.
1296 However it may not be recognized properly if correct code page is not
1297 loaded or it is mounted onto a system that does not support DBCS volume
1300 @param aName The volume label.
1301 @param aDrive The drive containing the media whose label is to be set.
1302 Specify a drive in the range EDriveA to EDriveZ for
1304 The default drive is the session default drive KDefaultDrive.
1306 @return KErrNone, if successful;
1307 KErrNotReady, if the drive contains no media;
1308 otherwise one of the other system-wide error codes.
1310 @capability DiskAdmin
1313 @see TVolumeInfo::iName
1317 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsSetVolumeLabel, MODULEUID,
1318 Handle(), aName, aDrive);
1320 TInt r = SendReceive(EFsSetVolume,TIpcArgs(&aName,aDrive));
1322 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetVolumeLabelReturn, MODULEUID, r);
1329 EFSRV_EXPORT_C TInt RFs::Subst(TDes& aPath,TInt aDrive) const
1331 Gets the path assigned to a drive letter by an earlier call to SetSubst().
1333 To find out whether a drive letter has been substituted, first get the drive
1334 information, using Drive(), and then test the value of the KDriveAttSubsted bit
1335 provided by TDriveInfo::iDriveAtt.
1337 @param aPath On return, contains the path which has been assigned to the
1338 drive. If the drive letter has not been substituted, this argument
1339 returns an empty descriptor.
1340 @param aDrive The drive which is the subject of the enquiry. Specify a number
1341 in the range 0 (EDriveA) to 25 (>EDriveZ) for drives
1342 A to Z. The default drive is the session default
1343 drive KDefaultDrive.
1345 @return KErrNone, if successful, otherwise one of the other
1346 system-wide error codes.
1353 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsSubst, MODULEUID, Handle(), aPath, aDrive);
1354 TInt r = SendReceive(EFsSubst,TIpcArgs(&aPath,aDrive));
1356 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSubstReturn, MODULEUID, r);
1363 EFSRV_EXPORT_C TInt RFs::SetSubst(const TDesC& aPath,TInt aDrive)
1365 Assigns a path to a drive letter.
1367 Whenever that drive letter is used, it will be translated into a reference
1368 to the path specified here. To clear a drive substitution, specify an empty
1369 descriptor for aPath.
1371 Note that the substituted path is text-only. Its components need not
1372 be syntactically correct, nor must they be valid at the time the substitution
1373 is set. Any component may be deleted, removed or unmounted while the
1374 substitution is set.
1376 @param aPath The path to be assigned to the drive letter. If a drive letter
1377 is specified in the path, it must not itself be substituted or
1378 redirected, or the function will return an error. If no drive is
1379 specified, the drive contained in the default session path is
1380 used, and if no path is specified, the default session path is
1381 used. If a filename or extension is included in the path,
1382 the function will return an error. Therefore, the final component
1383 in the path must have a trailing backslash to indicate that it is
1386 @param aDrive The drive to which a path is to be assigned. Specify a number
1387 in the range 0 (EDriveA) to 25 (EDriveZ) for drives
1388 A to Z. Must not be local, ROM, or redirected, otherwise an
1389 error is returned. May be substituted, but only if the function
1390 is being used to clear the substitution. If the same drive is
1391 specified in the path, the function will return an error.
1392 The default drive is the session default drive
1395 @return KErrNone, if successful; otherwise one of the other system-wide
1398 @capability DiskAdmin
1399 @capability Dependent If aPath is /Sys then Tcb capability is required.
1400 @capability Dependent If aPath begins with /Private and does not match this process' SID
1401 then AllFiles capability is required.
1402 @capability Dependent If aPath is /Resource then Tcb capability is required.
1405 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsSetSubst, MODULEUID, Handle(), aPath, aDrive);
1406 TInt r = SendReceive(EFsSetSubst,TIpcArgs(&aPath,aDrive));
1408 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetSubstReturn, MODULEUID, r);
1415 EFSRV_EXPORT_C TInt RFs::RealName(const TDesC& aName,TDes& aResult) const
1417 Gets the real name of a file.
1419 This is used in circumstances where a file system needs to
1420 mangle Symbian OS natural names so that it can store them on that file
1423 @param aName Contains the name by which the file is normally referred.
1424 @param aResult On return, contains the real name of the file, comprising the
1425 full path, including the drive letter.
1427 @return KErrNone if successful, otherwise one of the other
1428 system-wide error codes.
1430 @capability Dependent If aName is /Sys then AllFiles capability is required.
1431 @capability Dependent If aName begins with /Private and does not match this process' SID
1432 then AllFiles capability is required.
1436 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsRealName, MODULEUID, Handle(), aName);
1437 TInt r = SendReceive(EFsRealName,TIpcArgs(&aName,&aResult));
1439 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsRealNameReturn, MODULEUID, r, aResult);
1447 Gets the serial number of media.
1449 Only local drive is allowed. Substed drive number will return KErrNotSupported.
1451 @param aSerialNum Contains serial number on successful return.
1452 @param aDrive Drive number.
1454 @return KErrNone if successful;
1455 KErrNotSupported if media doesn't support serial number (e.g. substed drives);
1456 KErrBadName if drive number is invalid;
1457 otherwise one of system-wide error codes.
1459 @see TMediaSerialNumber
1461 EFSRV_EXPORT_C TInt RFs::GetMediaSerialNumber(TMediaSerialNumber& aSerialNum, TInt aDrive)
1463 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsGetMediaSerialNumber, MODULEUID, Handle(), aDrive);
1464 TInt r = SendReceive(EFsGetMediaSerialNumber, TIpcArgs(&aSerialNum, aDrive));
1466 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetMediaSerialNumberReturn, MODULEUID, r, aSerialNum);
1473 EFSRV_EXPORT_C TInt RFs::SessionPath(TDes& aPath) const
1475 Gets the session path.
1477 When a client connects to the file server, its session path is initialised to
1478 the system default path. The session path of an existing client can only be
1479 changed by this function.
1481 @param aPath On return, contains the session path, including a trailing
1484 @return KErrNone if successful, otherwise one of the other
1485 system-wide error codes.
1488 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsSessionPath, MODULEUID, Handle());
1489 TInt r = SendReceive(EFsSessionPath,TIpcArgs(&aPath));
1491 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsSessionPathReturn, MODULEUID, r, aPath);
1498 EFSRV_EXPORT_C TInt RFs::SetSessionPath(const TDesC& aPath)
1500 Sets the session path for the current file server client.
1502 When the client first connects to the file server, its session path
1503 is initialised to the system default path.
1505 Note that the session path is text-only. It does not cause any locking.
1506 Thus, although the path must be syntactically correct, its components
1507 do not need to be valid at the time the path is set, and any component may be
1508 deleted, removed or unmounted while the path is set.
1510 @param aPath The new session path. Consists of a drive and path. Normally, a
1511 drive should be specified, but if not, the drive specified in
1512 the existing session path is preserved. If a file is specified,
1513 then the function fails and returns an error code. Therefore,
1514 the final component in the path must have a trailing backslash
1515 to indicate that it is a directory. All components of the
1516 path must be syntactically correct, for example, wildcard
1517 characters and double backslashes are not allowed in any
1520 @return KErrNone if successful, otherwise one of the other
1521 system-wide error codes.
1523 @capability Dependent If aPath is /Sys then AllFiles capability is required.
1524 @capability Dependent If aPath begins with /Private and does not match this process' SID
1525 then AllFiles capability is required.
1529 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsSetSessionPath, MODULEUID, Handle(), aPath);
1530 TInt r = SendReceive(EFsSetSessionPath,TIpcArgs(&aPath));
1532 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetSessionPathReturn, MODULEUID, r);
1543 It should be a sub-directory of an existing directory and its name should be
1544 unique within its parent directory, otherwise the function returns error code KErrAlreadyExists.
1546 Note that if a filename is specified in the argument, it is ignored.
1547 Therefore, there should be a trailing backslash after the final
1548 directory name in the argument to indicate that it is a directory, not a filename.
1550 For example, following code will create directory "C:\\DIR1\\"
1553 fs.MkDir(_L("C:\\DIR1\\"));
1556 The last line in the following example will result in KErrAlreadyExists because "DIR2" doesn't have a trailing backslash,
1557 therefore is considered as a file name and discarded. Directory "C:\\DIR1\\" has already been created.
1560 fs.MkDir(_L("C:\\DIR1\\")); // shall create DIR1 in the root directory
1561 fs.MkDir(_L("C:\\DIR1\\DIR2")); // No trailing backslash, fails with KErrAlreadyExists
1564 This example will always fail because "DIR1" doesn't have a trailing backslash and discarded while the root
1565 directory always exists.
1568 fs.MkDir(_L("C:\\DIR1")); // No trailing backslash, will always fail with KErrAlreadyExists
1571 Note, the following case
1574 fs.MkDir(_L("C:\\example.txt\\")); // would normally create a directory "c:\\example.txt\\" with KErrNone
1577 But if there is a file named "example.txt", which exists at the same location, KErrAccessDenied is returned.
1579 Note also that because this method can return an error code (eg. because
1580 the disk is full) before checking whether the path already exists, it
1581 is not appropriate to use it just to work out whether a path exists or not.
1583 See MkDirAll(), which may also create intermediate directories.
1585 @param aPath The name of the new directory. Any path components which are
1586 not specified here will be taken from the session path.
1587 The directory name shall not contain wild cards ('?' or '*' characters)
1588 and illegal characters like '<', '>', ':', '"', '/', '|' and '\000'.
1589 The directory name containing only whilte space characters
1590 (See TChar::IsSpace()) is also illegal.
1592 @return KErrNone if successful, otherwise one of the other
1593 system-wide error codes. Even if another error code is returned,
1594 (for example, if the disk is full) it is still possible that the
1595 path may already exist.
1597 @capability Dependent If aPath is /Sys then Tcb capability is required.
1598 @capability Dependent If aPath begins with /Private and does not match this process' SID
1599 then AllFiles capability is required.
1600 @capability Dependent If aPath is /Resource then Tcb capability is required.
1604 EFSRV_EXPORT_C TInt RFs::MkDir(const TDesC& aPath)
1606 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsMkDir, MODULEUID, Handle(), aPath);
1607 TInt r = SendReceive(EFsMkDir,TIpcArgs(&aPath,NULL));
1609 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMkDirReturn, MODULEUID, r);
1618 Makes one or more directories.
1620 Any valid path component specified in aPath which does not already exist is
1621 created as a directory.
1623 Note that if a filename is specified in the argument, it is ignored.
1624 Therefore, there should be a trailing backslash after the final
1625 directory name in the argument to indicate that it is a directory, not a
1628 See also notes on RFs::MkDir() about trailing backslashes in directory names.
1630 Note also that because this method can return an error code (eg. because
1631 the disk is full) before checking whether the path already exists, it
1632 is not appropriate to use it just to work out whether a path exists or not.
1634 See MkDir(), which creates only a single new directory.
1636 @param aPath The path name specifiying the directory or directories to
1637 create. If the function completes successfully, this path
1638 identifies a valid directory. Any path components which are not
1639 specified here are taken from the session path.
1641 @return KErrNone if successful, otherwise one of the other
1642 system-wide error codes. Even if another error code is returned,
1643 (for example, if the disk is full) it is still possible that the
1644 path may already exist.
1647 @capability Dependent If aPath is /Sys then Tcb capability is required.
1648 @capability Dependent If aPath begins with /Private and does not match this process' SID
1649 then AllFiles capability is required.
1650 @capability Dependent If aPath is /Resource then Tcb capability is required.
1654 EFSRV_EXPORT_C TInt RFs::MkDirAll(const TDesC& aPath)
1656 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsMkDirAll, MODULEUID, Handle(), aPath);
1657 TInt r = SendReceive(EFsMkDir,TIpcArgs(&aPath,TRUE));
1659 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsMkDirAllReturn, MODULEUID, r);
1666 EFSRV_EXPORT_C TInt RFs::RmDir(const TDesC& aPath)
1668 Removes a directory.
1670 The directory must be empty and cannot be the root directory.
1672 Note that if a filename is specified in the argument, it is
1675 For example, following code will result in directory "C:\\SRC\\" being removed as long as
1676 it is empty, the existance of "ENTRY" will not be checked:
1679 fs.RmDir(_L("C:\\SRC\\ENTRY"));
1682 Similarly, following code will try to remove "C:\\SRC\\" instead of "C:\\SRC\DIR\\":
1684 fs.RmDir(_L("C:\\SRC\\DIR"));
1687 Therefore, there should be a trailing backslash after the final
1688 directory name in the argument to indicate that it is a directory, not a
1691 See class CFileMan for information on deleting a
1692 non-empty directory and all of its contents.
1694 @param aPath The path name of the directory to be removed. Any path components
1695 which are not specified here are taken from the session path. Only
1696 the lowest-level directory identified is removed.
1698 @return KErrNone, if successful;
1699 KErrInUse, if trying to remove a non-empty directory or root directory;
1700 otherwise, one of the other system-wide error codes.
1702 @capability Dependent If aPath is /Sys then Tcb capability is required.
1703 @capability Dependent If aPath begins with /Private and does not match this process' SID
1704 then AllFiles capability is required.
1705 @capability Dependent If aPath is /Resource then Tcb capability is required.
1710 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsRmDir, MODULEUID, Handle(), aPath);
1711 TInt r = SendReceive(EFsRmDir,TIpcArgs(&aPath));
1713 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsRmDirReturn, MODULEUID, r);
1720 void RFs::GetDirL(const TDesC& aName,const TUidType& aUidType,TUint aKey,CDir*& aFileList,RDir& aDir) const
1722 // Create a dir array. Leave on any error.
1726 User::LeaveIfError(aDir.Open((RFs& )*this,aName,aUidType));
1727 DoGetDirL(aKey,aFileList,aDir);
1730 void RFs::GetDirL(const TDesC& aName,TUint anAttMask,TUint aKey,CDir*& aFileList,RDir& aDir) const
1732 // Create a dir array. Leave on any error.
1737 User::LeaveIfError(aDir.Open((RFs& )*this,aName,anAttMask));
1738 DoGetDirL(aKey,aFileList,aDir);
1741 void RFs::GetDirL(const TDesC& aName,TUint anAttMask,TUint aKey,CDir*& aFileList,CDir*& aDirList,RDir& aDir) const
1743 // Create a dir array. Leave on any error.
1748 GetDirL(aName,anAttMask|KEntryAttDir,aKey,aFileList,aDir);
1749 aFileList->ExtractL(!(anAttMask&KEntryAttDir),aDirList);
1752 void RFs::DoGetDirL(TUint aKey,CDir*& aFileList,RDir& aDir) const
1754 // Create a dir array. Leave on any error.
1758 aFileList=CDir::NewL();
1760 TEntryArray* pArray=new(ELeave) TEntryArray;
1761 CleanupStack::PushL(pArray);
1763 TEntryArray& array=*pArray;
1767 if (r==KErrNone || r==KErrEof)
1769 TInt count=array.Count();
1774 aFileList->AddL(array[i++]);
1776 }while (r==KErrNone);
1778 CleanupStack::PopAndDestroy();
1779 if (!(r==KErrNone || r==KErrEof))
1781 aFileList->Compress();
1782 if (aKey==ESortNone)
1785 r=aFileList->Sort(aKey);
1793 EFSRV_EXPORT_C TInt RFs::GetDir(const TDesC& aName,const TUidType& aUidType,TUint aKey,CDir*& aFileList) const
1795 Gets a filtered list of a directory's contents by UID type.
1797 The aUidType parameter determines which file entry types should be listed.
1798 The sort key determines the order in which they are listed.
1802 1. The function sets aFileList to NULL, and then allocates memory for it before
1803 appending entries to the list. Therefore, aFileList should have no memory
1804 allocated to it before this function is called, otherwise this memory
1805 will become orphaned.
1807 2. The caller of this function is responsible for deleting aFileList after
1808 the function has returned.
1810 @param aName The name of the directory for which a listing is required.
1811 Wildcards may be used to specify particular files.
1812 @param aUidType Only those files whose UIDs match those specified within this
1813 UID type will be included in the file list. Any, or all, of
1814 the three UIDs within the UID type may be omitted.
1815 Any UID which is omitted acts in a similar manner to
1816 a wildcard character, matching to all UIDs.
1817 @param aKey The sort key. This is a set of flags indicating the order in
1818 which the entries are to be sorted. These flags are defined
1820 @param aFileList On return contains a filtered list of directory and file entries.
1822 @return KErrNone if successful, otherwise one of the other
1823 system-wide error codes.
1828 TRACEMULT6(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir1, MODULEUID,
1829 Handle(), aName, aUidType[0].iUid, aUidType[1].iUid, aUidType[2].iUid, aKey);
1832 TRAPD(r,GetDirL(aName,aUidType,aKey,aFileList,d))
1840 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir1Return, MODULEUID, r);
1847 EFSRV_EXPORT_C TInt RFs::GetDir(const TDesC& aName,TUint anAttMask,TUint aKey,CDir*& aFileList) const
1849 Gets a filtered list of a directory's contents.
1851 The bitmask determines which file and directory entry types should be listed.
1852 The sort key determines the order in which they are listed.
1856 1. If sorting by UID (as indicated when the ESortByUid bit is OR'ed with
1857 the sort key), then UID information will be included in the listing
1858 whether or not KEntryAttAllowUid is specified in anAttMask.
1860 2. The function sets aFileList to NULL, and then allocates memory for it before
1861 appending entries to the list. Therefore, aFileList should have no memory
1862 allocated to it before this function is called, otherwise this memory will
1865 3. The caller of this function is responsible for deleting aFileList after
1866 the function has returned.
1868 @param aName The name of the directory for which a listing is required.
1869 Wildcards may be used to specify particular files.
1870 @param anAttMask Bitmask indicating the attributes of interest. Only files and
1871 directories whose attributes match those specified here can be
1872 included in the listing. For more information,
1873 see KEntryAttMatchMask and the other directory entry details.
1874 Also see KEntryAttNormal and the other file or directory attributes.
1875 @param aKey The sort key. This is a set of flags indicating the order in
1876 which the entries are to be sorted. These flags are defined
1878 @param aFileList On return contains a filtered list of directory and file entries.
1880 @return KErrNone if successful, otherwise one of the other
1881 system-wide error codes.
1886 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir2, MODULEUID, Handle(), aName, anAttMask, aKey);
1889 if ((aKey&0xff)==ESortByUid)
1890 anAttMask|=KEntryAttAllowUid;
1891 TRAPD(r,GetDirL(aName,anAttMask,aKey,aFileList,d))
1899 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir2Return, MODULEUID, r);
1906 EFSRV_EXPORT_C TInt RFs::GetDir(const TDesC& aName,TUint anAttMask,TUint aKey,CDir*& aFileList,CDir*& aDirList) const
1908 Gets a filtered list of the directory and file entries contained in
1909 a directory, and a list of the directory entries only.
1911 The bitmask determines which file and directory entry types should be listed in
1912 aFileList. The contents of the second list, aDirList are not affected by the bitmask; it
1913 returns all directory entries contained in directory aName. The
1914 sort key determines the order in which both lists are sorted.
1918 1. If sorting by UID (as indicated when the ESortByUid bit is OR'ed with
1919 the sort key), then UID information will be included in the listing
1920 whether or not KEntryAttAllowUid is specified in anAttMask.
1922 2. The function sets both aFileList and aDirList to NULL, and then allocates
1923 memory to them before appending entries to the lists. Therefore, aFileList
1924 and aDirList should have no memory allocated to them before this
1925 function is called, otherwise the allocated memory will become orphaned.
1927 3. The caller of this function is responsible for deleting aFileList
1928 and aDirList after the function has returned.
1930 @param aName The name of the directory for which a listing is required.
1931 Wildcards may be used to specify particular files.
1932 @param anAttMask Bitmask indicating the attributes of interest. Only files and
1933 directories whose attributes match those specified here can be
1934 included in aFileList. aDirList is unaffected by this mask.
1935 For more information, see KEntryAttMatchMask and the other
1936 directory entry details.
1937 Also see KEntryAttNormal and the other file or directory
1939 @param aKey The sort key. This is a set of flags indicating the order in
1940 which the entries in both lists are to be sorted. These flags
1941 are defined by TEntryKey.
1942 @param aFileList On return contains a filtered list of directory and
1944 @param aDirList On return contains a filtered list of directory entries only.
1946 @return KErrNone if successful, otherwise one of the other
1947 system-wide error codes.
1952 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir3, MODULEUID, Handle(), aName, anAttMask, aKey);
1955 if (aKey&ESortByUid)
1956 anAttMask|=KEntryAttAllowUid;
1957 TRAPD(r,GetDirL(aName,anAttMask,aKey,aFileList,aDirList,d))
1967 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsGetDir3Return, MODULEUID, r);
1974 EFSRV_EXPORT_C TInt RFs::Parse(const TDesC& aName,TParse& aParse) const
1976 Parses a filename specification.
1978 Parsing is done with wildcard resolution, using the session path as
1979 the default. You can then use TParse's getter functions to extract individual
1980 components of the resulting name. All the path components that are included
1981 in aName are put into the resulting filename. Any components that are still
1982 missing are taken from the session path.
1999 fp.Set(name,NULL,&fs.SessionPath());
2002 Note that the function does not check for illegal characters, or for
2003 illegal path components in either of the paths specified.
2005 @param aName The file name to be parsed, using the session path to provide
2006 the missing components.
2007 @param aParse A TParse objct that provides functions for
2008 extracting individual components of the resulting file name.
2010 @return KErrNone if successful, otherwise one of the other
2011 system-wide error codes.
2014 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsParse1, MODULEUID, Handle(), aName);
2015 TFileName session_path;
2016 TInt r = SessionPath(session_path);
2018 r = aParse.Set(aName, NULL, &session_path);
2020 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsParse1Return, MODULEUID, r);
2027 EFSRV_EXPORT_C TInt RFs::Parse(const TDesC& aName,const TDesC& aRelated,TParse& aParse) const
2029 Parses a filename specification, specifying related file path components.
2031 Parsing is done with wildcard resolution, using the session path as
2032 the default. You can then use TParse's getter functions to extract individual
2033 components of the resulting name. All the path components that are included
2034 in aName are put into the resulting filename. Any missing components are taken
2035 from the optional aRelated argument, which has the next order of precedence.
2036 Finally, any components that are still missing are taken from the session path.
2044 fs.Parse(name,related,fp);
2053 fp.Set(name,related,&fs.SessionPath());
2056 Note that the function does not check for illegal characters, or for
2057 illegal path components in any of the paths specified.
2059 @param aName The file name to be parsed, using the session path and the
2060 related path to provide the missing components.
2061 @param aRelated The related file specification.
2062 @param aParse A TParse objct that provides functions for
2063 extracting individual components of the resulting file name.
2065 @return KErrNone if successful, otherwise one of the other
2066 system-wide error codes.
2069 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsParse2, MODULEUID, Handle(), aName, aRelated);
2070 TFileName session_path;
2071 TInt r = SessionPath(session_path);
2073 r = aParse.Set(aName, &aRelated, &session_path);
2075 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsParse2Return, MODULEUID, r);
2082 EFSRV_EXPORT_C TInt RFs::Delete(const TDesC& aName)
2084 Deletes a single file.
2086 Wildcards are not allowed in either the file name or the extension,
2087 otherwise an error is returned.
2089 Note that the file must be closed and must not be read-only.
2090 Hidden files can be deleted but system files cannot.
2092 See class CFileMan for information on deleting multiple files.
2094 @param aName The name of the file to be deleted. Any path components which
2095 are not specified here will be taken from the session path.
2097 @return KErrNone if successful, otherwise one of the other
2098 system-wide error codes.
2100 @capability Dependent If aName is /Sys then Tcb capability is required.
2101 @capability Dependent If aName begins with /Private and does not match this process' SID
2102 then AllFiles capability is required.
2103 @capability Dependent If aName is /Resource then Tcb capability is required.
2108 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsDelete, MODULEUID, Handle(), aName);
2109 TInt r = SendReceive(EFsDelete,TIpcArgs(&aName));
2111 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsDeleteReturn, MODULEUID, r);
2118 EFSRV_EXPORT_C TInt RFs::Rename(const TDesC& anOldName,const TDesC& aNewName)
2120 Renames a single file or directory.
2122 It can also be used to move a file or directory by specifying different
2123 destination and source directories. If so, the destination and source
2124 directories must be on the same drive. If a directory is moved, then
2125 the directory structure beneath it is also moved.
2127 If a directory specified by aNewName is different from one specified
2128 by anOldName, then the file or directory is moved to the new directory.
2129 The file or directory cannot be moved to another device by this means,
2130 either explicitly (by another drive specified in the name) or implicitly
2131 (because the directory has been mapped to another device with SetSubst().
2133 The function fails and returns an error code in the following
2136 1. If either the old or new name includes wildcards.
2138 2. If a file or directory with the new name already exists in
2139 the target directory. Overwriting is not permitted.
2141 3. If file anOldName does not exist, or is open.
2143 Read-only, system and hidden files may be renamed. The renamed
2144 file's attributes are preserved.
2146 Note that when this function is operating on directories, a trailing backslash
2147 is not required after the final directory name in either anOldName or aNewName.
2149 See class CFileMan for information on renaming multiple files.
2151 @param anOldName File or directory to be renamed. Any path components which are
2152 not specified here will be taken from the session path.
2153 @param aNewName Path specifying the new name for the file or directory and/or
2154 its new parent directory. All directories specified in this path
2156 Any path components which are not specified here will be taken
2157 from the session path.
2159 @return KErrNone if successful, otherwise one of the other
2160 system-wide error codes.
2162 @capability Dependent If either anOldName or aNewName is /Sys then Tcb capability is required.
2163 @capability Dependent If either anOldName or aNewName begins with /Private and does not match
2164 this process' SID then AllFiles capability is required.
2165 @capability Dependent If either anOldName or aNewName is /Resource then Tcb capability is required.
2170 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsRename, MODULEUID, Handle(), anOldName, aNewName);
2173 if (anOldName.Length() <= 0 || aNewName.Length() <= 0 )
2176 r = SendReceive(EFsRename,TIpcArgs(&anOldName,&aNewName));
2178 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsRenameReturn, MODULEUID, r);
2185 EFSRV_EXPORT_C TInt RFs::Replace(const TDesC& anOldName,const TDesC& aNewName)
2187 Replaces a single file with another.
2189 This function does not support the use of wildcards. Unlike Rename(), it only
2192 This function operates as follows:
2194 1. if the aNewName file does not exist, it is created.
2196 2. anOldName's contents, attributes and the date and time of its last
2197 modification are copied to file aNewName, overwriting any existing contents
2198 and attribute details.
2200 3. anOldName is deleted.
2202 anOldName may be hidden, read-only or a system file. However,
2203 neither anOldName, nor, if it exists, aNewName, can be open;
2204 aNewName must not be read-only.
2205 Both files must be on the same drive.
2207 @param anOldName The file to be replaced. Must exist and must be closed. It is
2208 deleted by this function.
2209 @param aNewName The file to replace anOldName. Does not need to exist, but if
2210 it does exist, it must be closed. If it exists, its name
2211 remains unchanged but its contents, attributes and the date
2212 and time of its last modification are replaced by those
2214 If it does not exist, it will be created and is assigned
2215 the contents and attributes of anOldName. Must not be followed
2216 by a trailing backslash.
2218 @return KErrNone, if successful;
2219 KErrAccessDenied, if an attempt is made to replace a directory;
2220 otherwise one of the other system-wide error codes.
2222 @capability Dependent If either anOldName or aNewName is /Sys then Tcb capability is required.
2223 @capability Dependent If either anOldName or aNewName begins with /Private and does not match
2224 this process' SID then AllFiles capability is required.
2225 @capability Dependent If either anOldName or aNewName is /Resource then Tcb capability is required.
2229 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsReplace, MODULEUID, Handle(), anOldName, aNewName);
2230 TInt r = SendReceive(EFsReplace,TIpcArgs(&anOldName,&aNewName));
2232 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsReplaceReturn, MODULEUID, r);
2239 EFSRV_EXPORT_C TInt RFs::Att(const TDesC& aName,TUint& aVal) const
2241 Gets a file's attributes.
2243 @param aName The filename. Any path components which are not specified here
2244 will be taken from the session path.
2245 @param aVal On return, the individual bits within the byte indicate which
2246 attributes have been set. For more information see KEntryAttNormal
2247 and the other file/directory attributes.
2249 @return KErrNone if successful, otherwise one of the other
2250 system-wide error codes.
2252 @capability Dependent If aName contains /sys/ then AllFiles capability is required.
2253 @capability Dependent If aName contains /Private/ and does not match
2254 this process' SID then AllFiles capability is required.
2256 @see KEntryAttNormal
2259 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsAtt, MODULEUID, Handle(), aName);
2262 TInt r=Entry(aName,e);
2266 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFsAttReturn, MODULEUID, r, aVal);
2273 EFSRV_EXPORT_C TInt RFs::SetAtt(const TDesC& aName,TUint aSetAttMask,TUint aClearAttMask)
2275 Sets or clears the attributes of a single file or directory.
2277 The function uses two bitmasks. The first bitmask specifies the attributes
2278 to be set; the second specifies the attributes to be cleared.
2280 An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote
2281 attributes have no effect.
2283 @param aName File or directory name. Any path components which are not
2284 specified here will be taken from the session path. Must
2285 not include wildcard characters. The file must be closed.
2286 @param aSetAttMask Bitmask indicating the attributes to be set.
2287 @param aClearAttMask Bitmask indicating the attributes to be cleared. For more
2288 information, see KEntryAttNormal and the other file or
2289 directory attributes.
2291 @return KErrNone if successful, otherwise one of the other
2292 system-wide error codes.
2294 @panic FSCLIENT 21 if any attribute appears in both bitmasks.
2297 @capability Dependent If aName is /Sys then Tcb capability is required.
2298 @capability Dependent If aName begins with /Private and does not match
2299 this process' SID then AllFiles capability is required.
2300 @capability Dependent If aName is /Resource then Tcb capability is required.
2306 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsSetAtt, MODULEUID,
2307 Handle(), aName, aSetAttMask, aClearAttMask);
2309 TInt r = SetEntry(aName,TTime(0),aSetAttMask,aClearAttMask);
2311 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetAttReturn, MODULEUID, r);
2318 EFSRV_EXPORT_C TInt RFs::Modified(const TDesC& aName,TTime& aTime) const
2320 Gets the last modification date and time of a file or a directory,
2323 If there has been no modification, the function gets the date and
2324 time of the file or directory's creation.
2326 @param aName File or directory name.
2327 @param aTime On return, contains the date and time of the file or
2328 directory's last modification in universal time.
2330 @return KErrNone if successful, otherwise one of the other
2331 system-wide error codes.
2333 @capability Dependent If aName contains /sys/ then AllFiles capability is required.
2334 @capability Dependent If aName contains /Private/ and does not match
2335 this process' SID then AllFiles capability is required.
2339 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsModified, MODULEUID, Handle(), aName);
2342 TInt r=Entry(aName,e);
2346 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFsModifiedReturn, MODULEUID, r, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()));
2353 EFSRV_EXPORT_C TInt RFs::SetModified(const TDesC& aName,const TTime& aTime)
2355 Sets the date and time that the contents of a file or directory
2356 were modified, in UTC.
2358 @param aName File or directory name.
2359 @param aTime The new date and time that the file or directory was modified
2362 @return KErrNone if successful;
2363 KErrInUse, if the file is open;
2364 otherwise one of the other system-wide error codes.
2366 @capability Dependent If aName is /Sys then Tcb capability is required.
2367 @capability Dependent If aName begins with /Private and does not match
2368 this process' SID then AllFiles capability is required.
2369 @capability Dependent If aName is /Resource then Tcb capability is required.
2373 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsSetModified, MODULEUID, Handle(), aName, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()) );
2375 TInt r = SetEntry(aName,aTime,KEntryAttModified,0);
2377 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetModifiedReturn, MODULEUID, r);
2384 EFSRV_EXPORT_C TInt RFs::Entry(const TDesC& aName,TEntry& anEntry) const
2386 Gets the entry details for a file or directory.
2388 This information includes UID information.
2390 @param aName Name of file or directory.
2391 @param anEntry On return, contains the entry details for the file or directory. TEntry::iModified contains UTC date and time.
2393 @return KErrNone if successful, otherwise one of the other
2394 system-wide error codes.
2396 @capability Dependent If aName contains "\\Sys\\" and includes an additional file or directory then AllFiles capability
2397 is required. For example, the paths "c:\\sys" and "c:\\sys\\" will always be readable, whereas
2398 the path "c:\\sys\\abc\\" will only be readable with AllFiles capability.
2400 @capability Dependent If aName contains \\Private\\ and includes an additional file, or a directory which does not match
2401 this process' SID, then AllFiles capability is required. For example, the paths "c:\\private" and
2402 "c:\\private\\" will always be readable, whereas the path "c:\\private\\<n>\\" will only be
2403 readable with AllFiles capability or if <n> matches the process' SID.
2406 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsEntry, MODULEUID, Handle(), aName);
2407 TPckg<TEntry> e(anEntry);
2408 TInt r = SendReceive(EFsEntry,TIpcArgs(&aName,&e));
2410 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFsEntryReturn, MODULEUID,
2412 I64LOW(anEntry.iModified.Int64()), I64HIGH(anEntry.iModified.Int64()),
2420 EFSRV_EXPORT_C TInt RFs::SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask)
2422 Sets both the attributes and the last modified date and time for a file or directory.
2424 The function uses two bitmasks. The first bitmask determines
2425 which attributes should be set. The second bitmask determines which should be cleared.
2427 An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote
2428 attributes have no effect.
2430 @param aName File or directory name.
2431 @param aTime New date and time. UTC date and time should be used.
2432 @param aSetAttMask Bitmask indicating which attributes are to be set.
2433 @param aClearAttMask Bitmask indicating which attributes are cleared. For more
2434 information, see KEntryAttNormal, and the other file
2435 or directory attributes.
2437 @return KErrNone, if successful;
2438 KErrInUse, if the file is open;
2439 otherwise one of the other system-wide error codes.
2441 @panic FSCLIENT 21 if any attribute appears in both bitmasks.
2443 @capability Dependent If aName is /Sys then Tcb capability is required.
2444 @capability Dependent If aName begins with /Private and does not match
2445 this process' SID then AllFiles capability is required.
2446 @capability Dependent If aName is /Resource then Tcb capability is required.
2448 @see KEntryAttNormal
2450 @see KEntryAttVolume
2453 TRACEMULT6(UTF::EBorder, UTraceModuleEfsrv::EFsSetEntry, MODULEUID,
2455 I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()),
2456 aSetAttMask, aClearAttMask);
2458 __ASSERT_ALWAYS((aSetAttMask&aClearAttMask)==0,Panic(EAttributesIllegal));
2459 TPtrC8 timeBuf((TUint8*)&aTime,sizeof(TTime));
2460 TInt r = SendReceive(EFsSetEntry,TIpcArgs(&aName,&timeBuf,aSetAttMask,aClearAttMask));
2462 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetEntryReturn, MODULEUID, r);
2467 Reads data from a file without opening it.
2469 The contents of the file can be accessed regardless of the file's lock state.
2471 The file may be open by any number of other clients for reading or writing.
2472 In allowing such access to a file, the fileserver makes no guarantees as to
2473 the validity of the data it returns.
2475 @param aName Name of the file to be accessed.
2476 @param aPos The offset, in bytes, from the start of the file where
2477 reading is to start.
2478 @param aDes On return, contains the data read from the file. The length of
2479 the descriptor is set to the number of bytes read. If the
2480 specified offset lies beyond the end of the file, no data is
2481 read and the length of this descriptor is set to zero.
2482 @param aLength The number of bytes to be read from the file.
2484 @return KErrNone if successful,
2485 KErrArgument if aLength is negative,
2486 otherwise one of the other system-wide error codes.
2488 @panic FSCLIENT 19 if aPos negative.
2489 @panic FSCLIENT 27 if aLength is greater than the maximum length of
2490 the target descriptor.
2492 @capability Dependent If the path for aName starts with /Sys capability AllFiles is required
2493 @capability Dependent If the path for aName starts with /Private and this process does not have
2494 the relevant SID capability AllFiles is required
2497 EFSRV_EXPORT_C TInt RFs::ReadFileSection(const TDesC& aName,TInt64 aPos,TDes8& aDes,TInt aLength) const
2499 TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSection, MODULEUID,
2500 Handle(), aName, I64LOW(aPos), I64HIGH(aPos), aLength);
2502 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
2504 #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
2507 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSectionReturn, MODULEUID, KErrTooBig);
2510 if((aPos + aLength) > KMaxTInt)
2511 aLength = KMaxTInt - (TInt)aPos;
2513 if (aLength) // Number of characters to read
2515 __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength));
2520 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSectionReturn, MODULEUID, KErrNone);
2524 __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength));
2527 if(!(I64HIGH(aPos)))
2529 r = SendReceive(EFsReadFileSection,TIpcArgs(&aDes,&aName,I64LOW(aPos),aLength));
2533 TPckgC<TInt64> pkPos(aPos);
2534 r = SendReceive(EFsReadFileSection|KIpcArgSlot2Desc,TIpcArgs(&aDes,&aName,&pkPos,aLength));
2536 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSectionReturn, MODULEUID, r);
2544 EFSRV_EXPORT_C TInt RFs::ReadFileSection_RESERVED(const TDesC& aName,TInt aPos,TDes8& aDes,TInt aLength) const
2546 TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSection, MODULEUID,
2547 Handle(), aName, aPos, 0, aLength);
2549 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
2551 if (aLength) // Number of characters to read
2553 __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength));
2558 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSectionReturn, MODULEUID, KErrNone);
2562 __ASSERT_ALWAYS(aDes.MaxLength()>=aLength,Panic(EBadLength));
2564 TInt r = SendReceive(EFsReadFileSection,TIpcArgs(&aDes,&aName,aPos,aLength));
2566 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsReadFileSectionReturn, MODULEUID, r);
2573 EFSRV_EXPORT_C void RFs::ResourceCountMarkStart() const
2575 Marks the start of resource count checking.
2577 Typically, this function is called immediately after a client is connected
2578 to the file server, and before any resources are opened.
2581 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCountMarkStart, MODULEUID, Handle());
2583 RSessionBase::SendReceive(EFsResourceCountMarkStart);
2585 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCountMarkStartReturn, MODULEUID);
2591 EFSRV_EXPORT_C void RFs::ResourceCountMarkEnd() const
2593 Ends resource count checking. Typically, this function is called immediately
2594 before closing a session with the file server.
2596 @panic CSessionFs 2 if the number of resources opened since the start of resource
2597 count checking is not equal to the number of resources closed.
2600 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCountMarkEnd, MODULEUID, Handle());
2602 RSessionBase::SendReceive(EFsResourceCountMarkEnd);
2604 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCountMarkEndReturn, MODULEUID);
2610 EFSRV_EXPORT_C TInt RFs::ResourceCount() const
2612 Gets the number of currently open resources.
2614 The resource count is incremented by one: when a file or directory
2615 is opened, when a device is opened in preparation for formatting, when a direct access channel
2616 to a disk is opened.
2618 @return The number of resources currently open.
2621 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCount, MODULEUID, Handle());
2624 TPckg<TInt> pckg(count);
2625 SendReceive(EFsResourceCount,TIpcArgs(&pckg));
2626 TInt r = *(TInt*)pckg.Ptr();
2628 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsResourceCountReturn, MODULEUID, r);
2635 Checks the integrity of the disk on the specified drive.
2636 On FAT, this checks if a cluster number is invalid, if a cluster is allocated to
2637 more than one file entry, if an unallocated cluster is not set free, and if size
2638 of an entry is invalid.
2640 @param aDrive Path indicating the drive which contains the disk to be checked. If the drive
2641 information is not specified the current session drive is taken by default.
2642 Checkdisk is performed on the requested drive irrespective of the correctness or
2643 existance of the given path.
2645 @return KErrNone, if successful;
2646 1, if successful but a file cluster contains a bad value;
2647 2, if successful but two files are linked to the same cluster;
2648 3, if successful but an unallocated cluster contains a value;
2649 4, if successful but the size of a file is not equal to the number of clusters in chain;
2650 KErrNotReady, if the specified drive is empty;
2651 KErrNotSupported, if the drive cannot handle this request;
2652 KErrPermissionDenied, if the caller doesn't have DiskAdmin capability;
2653 Other system wide error codes may also be returned.
2655 @capability DiskAdmin
2657 EFSRV_EXPORT_C TInt RFs::CheckDisk(const TDesC& aDrive) const
2659 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsCheckDisk, MODULEUID, Handle(), aDrive);
2660 TInt r = SendReceive(EFsCheckDisk,TIpcArgs(&aDrive));
2662 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsCheckDiskReturn, MODULEUID, r);
2669 EFSRV_EXPORT_C TInt RFs::ScanDrive(const TDesC& aDrive) const
2671 Checks the specified drive for errors and corrects them. Specifically, it
2672 checks if long file name entries' IDs are in sequence and short name is valid,
2673 and file's allocated clusters are not used by other files.
2675 This does not run on the internal RAM drive, and only applies to a
2678 @param aDrive Path indicating the drive which contains the disk to be checked. If the drive
2679 information is not specified the current session drive is taken by default.
2680 ScanDrive is performed on the requested drive irrespective of the correctness or
2681 existance of the given path.
2683 @return KErrNone if successful,
2684 KErrPermissionDenied if caller doesn't have capability DiskAdmin,
2685 KErrInUse if drive is in use,
2686 otherwise one of the other system-wide error codes
2688 @capability DiskAdmin
2691 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsScanDrive, MODULEUID, Handle(), aDrive);
2692 TInt r = SendReceive(EFsScanDrive,TIpcArgs(&aDrive));
2694 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsScanDriveReturn, MODULEUID, r);
2701 EFSRV_EXPORT_C TInt RFs::GetShortName(const TDesC& aLongName,TDes& aShortName) const
2703 Gets the short filename associated with a VFAT long filename.
2705 The short filename has a limit of eight characters for the file name and three
2706 characters for the extension.
2708 @param aLongName The long filename. Any path components which are not
2709 specified here will be taken from the session path.
2710 If the path specifies a directory, it may or may not be
2711 followed by a trailing backslash.
2712 @param aShortName On return, contains the short filename associated with the file
2713 or directory specified in aLongName.
2715 @return KErrNone if successful, otherwise one of the other
2716 system-wide error codes.
2718 @capability Dependent If the path for aLongName starts with /Sys capability AllFiles is required
2719 @capability Dependent If the path for aLongName starts with /Private and this process does not
2720 have the relevant SID capability AllFiles is required
2723 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetShortName, MODULEUID, Handle(), aLongName);
2724 TInt r = SendReceive(EFsGetShortName,TIpcArgs(&aLongName,&aShortName));
2726 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetShortNameReturn, MODULEUID, r, aShortName);
2733 EFSRV_EXPORT_C TInt RFs::GetLongName(const TDesC& aShortName,TDes& aLongName) const
2735 Gets the long filename associated with a short (8.3) filename.
2737 A long filename has a limit of 256 characters for each component, as well as a
2738 limit of 256 characters for the entire path.
2740 @param aShortName The short file name. Any path components which are not
2741 specified here will be taken from the session path. If
2742 the path specifies a directory, it may or may not be followed
2743 by a trailing backslash.
2744 @param aLongName On return, contains the long version of the name.
2746 @return KErrNone if successful, otherwise one of the other
2747 system-wide error codes.
2749 @capability Dependent If the path for aShortName starts with /Sys capability AllFiles is required
2750 @capability Dependent If the path for aShortName starts with /Private and this process does not
2751 have the relevant SID capability AllFiles is required
2755 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetLongName, MODULEUID, Handle(), aShortName);
2756 TInt r = SendReceive(EFsGetLongName,TIpcArgs(&aShortName,&aLongName));
2758 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetLongNameReturn, MODULEUID, r, aLongName);
2765 EFSRV_EXPORT_C TInt RFs::IsFileOpen(const TDesC& aFileName,TBool& anAnswer) const
2767 Tests whether a file is open.
2769 This function is useful because several file based operations provided by
2770 the RFs class, for example: Delete(), Replace() and Rename(), require that
2773 @param aFileName The name of the file to test. Any path components which are
2774 not specified here will be taken from the session path. If a
2775 directory is specified instead of a file then KErrNone will be
2776 returned and anAnswer will be set to EFalse.
2777 @param anAnswer On return, true if the file is open, false if closed.
2779 @return KErrNone if successful, otherwise one of the other
2780 system-wide error codes.
2782 @capability Dependent If the path for aFileName starts with /Sys capability AllFiles is required
2783 @capability Dependent If the path for aFileName starts with /Private and this process does not
2784 have the relevant SID capability AllFiles is required
2791 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsIsFileOpen, MODULEUID, Handle(), aFileName);
2792 TPckg<TBool> b(anAnswer);
2793 TInt r = SendReceive(EFsIsFileOpen,TIpcArgs(&aFileName,&b));
2795 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFsIsFileOpenReturn, MODULEUID, r, anAnswer);
2802 TInt RFs::GetOpenFileList(TInt& aSessionNumber,TInt& aLocalPos,TThreadId& aThreadId,TEntryArray& anArray) const
2804 // Private function to get a list of open files
2807 TOpenFileListPos s(aSessionNumber,aLocalPos);
2808 TPckg<TOpenFileListPos> pS(s);
2809 TPckg<TThreadId> threadId(aThreadId);
2810 anArray.iCount=KCountNeeded;
2811 TInt r=SendReceive(EFsListOpenFiles,TIpcArgs(&pS,&threadId,&anArray.iBuf));
2812 aSessionNumber=s.iSession;
2813 aLocalPos=s.iEntryListPos;
2820 EFSRV_EXPORT_C TBool RFs::GetNotifyUser()
2822 Tests whether user notification of file read or write failure is in effect.
2824 @return True if notification in effect, false if not.
2827 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsGetNotifyUser, MODULEUID, Handle());
2830 TPckg<TInt> pckgNotify(notifyUser);
2831 SendReceive(EFsGetNotifyUser,TIpcArgs(&pckgNotify));
2832 TBool r = notifyUser;
2834 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsGetNotifyUserReturn, MODULEUID, r);
2841 EFSRV_EXPORT_C void RFs::SetNotifyUser(TBool aValue)
2843 Sets whether the user should be notified of file read or write failure.
2844 Note that if some drive is mounted as synchronous (see RFs::MountFileSystem), the user won't be
2845 notified about read/write failures on it.
2847 @param aValue ETrue, if user is to be notified of read or write failures;
2848 EFalse, for no notification.
2851 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsSetNotifyUser, MODULEUID, Handle(), aValue);
2852 SendReceive(EFsSetNotifyUser,TIpcArgs(aValue));
2854 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsSetNotifyUserReturn, MODULEUID);
2860 EFSRV_EXPORT_C TUint8* RFs::IsFileInRom(const TDesC& aFileName) const
2862 Gets a pointer to the specified file, if it is in ROM.
2864 Note that this is not a test of whether the file is on the Z: drive, as
2865 the Z: drive may consist of a ROM and another file system, using the composite
2866 file system. For example, the file system may be ROFS, and the underlying media
2869 @param aFileName The filename whose address is sought. Cannot include wildcards.
2870 Any path components which are not specified here will be taken
2871 from the session path.
2873 @return Address of the start of the file, if it is in ROM. This is NULL, if
2874 the file is not in ROM. Note that for the composite file system, the file
2875 might be on the Z: drive but in a non-ROM file system (i.e. ROFS), in
2876 which case the function still returns NULL.
2878 @capability Dependent If the path for aFileName starts with /Sys capability AllFiles is required
2879 @capability Dependent If the path for aFileName starts with /Private and this process does not
2880 have the relevant SID capability AllFiles is required
2884 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsIsFileInRom, MODULEUID, Handle(), aFileName);
2886 TPckgBuf<TUint8*> start;
2889 if (SendReceive(EFsIsFileInRom,TIpcArgs(&aFileName,&start))!=KErrNone)
2894 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsIsFileInRomReturn, MODULEUID, r);
2902 Tests whether a filename and path are syntactically correct.
2904 The following restrictions apply to the path and to its components:
2906 1. Wildcards are not allowed in any path component, including the filename and extension.
2907 2. Double backslashes are not allowed anywhere in the path
2908 3. The following 6 characters cannot appear in the path: < > : " / |
2909 4. Either or both of a filename or extension must be present. This means that a valid aFileName can not
2910 end with backslash (like "c:\\SomeName\\"), because it will mean that "SomeName" is a directory.
2912 5. The entire component following the final backslash (the filename and extension) cannot consist solely of space characters,
2913 or of a single or double dot.
2915 6. Spaces between the drive, if specified, and the first directory in the path are illegal, although there may be
2916 spaces between other path components, for example, between directories.
2918 7. If the path in aFileName is not fully specified, i.e. doesn't look like "c:\\Dir1\\File1.bin", all missing
2919 parts of the full path will be taken from the session path, @see RFs::SetSessionPath, @see RFs::SessionPath.
2920 In this case the session path must be set, otherwise this method will return EFalse.
2921 For example: for the case "\\file1.txt" only the drive letter will be taken from the session path;
2922 for the case "file1.txt" whole session path will be internally prepended to the "file1.txt" and whole path checked.
2923 Note that in this case total length of the name in the aFileName parameter and the session path shall not exceed KMaxFileName characters.
2926 @param aFileName The path to be checked for validity.
2927 May specify a filename alone, or an entire path specification, including drive letter.
2928 If a path is specified, all components are checked for validity.
2930 @return ETrue, if the name is valid (conforms to the mentioned above criteria); EFalse otherwise.
2932 EFSRV_EXPORT_C TBool RFs::IsValidName(const TDesC& aFileName) const
2934 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName1, MODULEUID, Handle(), aFileName);
2935 TBool returnInvalidChar=EFalse;
2936 TPckg<TBool> bPckg(returnInvalidChar);
2938 if (SendReceive(EFsIsValidName,TIpcArgs(&aFileName,&bPckg,NULL,NULL))!=KErrNone)
2942 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName1Return, MODULEUID, b);
2950 The following restrictions apply to the path and to its components:
2952 1. Wildcards are not allowed in any path component, including the filename and extension.
2953 2. Double backslashes are not allowed anywhere in the path
2954 3. The following 6 characters cannot appear in the path: < > : " / |
2955 4. Either or both of a filename or extension must be present. This means that a valid aFileName can not
2956 end with backslash (like "c:\\SomeName\\"), because it will mean that "SomeName" is a directory.
2958 5. The entire component following the final backslash (the filename and extension) cannot consist solely of space characters,
2959 or of a single or double dot.
2961 6. Spaces between the drive, if specified, and the first directory in the path are illegal, although there may be
2962 spaces between other path components, for example, between directories.
2964 7. If the path in aFileName is not fully specified, i.e. doesn't look like "c:\\Dir1\\File1.bin", all missing
2965 parts of the full path will be taken from the session path, @see RFs::SetSessionPath, @see RFs::SessionPath.
2966 In this case the session path must be set, otherwise this method will return EFalse.
2967 For example: for the case "\\file1.txt" only the drive letter will be taken from the session path;
2968 for the case "file1.txt" whole session path will be internally prepended to the "file1.txt" and whole path checked.
2969 Note that in this case total length of the name in the aFileName parameter and the session path shall not exceed KMaxFileName characters.
2971 @param aFileName The path to be checked for validity.
2972 May specify a filename alone, or an entire path specification, including drive letter.
2973 If a path is specified, all components are checked for validity.
2975 @param aBadChar reference to the variable that on return can contain illegal character from aFileName.
2976 1. if the filename and optional path in aFileName are valid, this method will return ETrue and aBadChar will be set to 0x00.
2977 2. if there is an illegal character in aFileName, this method will return EFalse and aBadChar will contain this illegal character.
2978 3. if there is no illegal characters in aFileName, but this is still not a valid filename (like "\\SomeName\\")
2979 this method will return EFalse and aBadChar will contain space ' ' or code 0x20.
2981 @return ETrue, if the name is valid (conforms to the mentioned above criteria); EFalse otherwise.
2983 EFSRV_EXPORT_C TBool RFs::IsValidName(const TDesC& aFileName,TText& aBadChar) const
2985 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName2, MODULEUID, Handle(), aFileName);
2986 TBool returnInvalidChar=ETrue;
2987 TPckg<TBool> boolPckg(returnInvalidChar);
2988 TPckg<TText> textPckg(aBadChar);
2990 if (SendReceive(EFsIsValidName,TIpcArgs(&aFileName,&boolPckg,&textPckg,NULL))!=KErrNone)
2994 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName2Return, MODULEUID, b, aBadChar);
2998 This API can be used to validate both directory and file names.
2999 If the name ends with a trailing backslash '\\' then it is considered to be a directory
3001 For example: "C:\\test\\" would mean a directory, whereas
3002 "C:\\test" would mean a file, both of which would be returned as a Valid Name.
3003 However a name such as "C:\\test\\\\" would be returned as an Invalid name with error code TError::ErrBadName
3005 The following restrictions apply to the path and to its components:
3007 1. Wildcards are not allowed in any path component, including the name and extension.
3008 2. Double backslashes are not allowed anywhere in the path
3009 3. The following 6 characters cannot appear in the path: < > : " / |
3010 4. The entire component following the final backslash (the filename and extension) cannot consist solely of space characters,
3011 or of a single or double dot.
3012 5. Spaces between the drive, if specified, and the first directory in the path are illegal, although there may be
3013 spaces between other path components, for example, between directories.
3014 6. If TNameValidParam::iUseSesssionPath is set to ETrue, and if the path in aName is not fully specified,
3015 i.e. doesn't look like "c:\\Dir1\\File1.bin", all missing parts of the full path will be taken from the session path,
3016 @see RFs::SetSessionPath, @see RFs::SessionPath.
3017 In this case the session path must be set, otherwise this method will return EFalse.
3018 For example: for the case "\\file1.txt" only the drive letter will be taken from the session path;
3019 for the case "file1.txt" whole session path will be internally prepended to the "file1.txt" and whole path checked.
3020 Note that in this case total length of the name in the aName parameter and the session path shall not exceed KMaxFileName characters.
3021 7. If TNameValidParam::iUseSesssionPath is set to EFalse, which is the default value, then
3022 the session path is not used to fill in the missing parts of the name as stated above.
3023 For example: for the case "file1.txt", session path will not be used to check the validity of the name.
3024 @param aName The path to be checked for validity.
3025 May specify a name alone, or an entire path specification, including drive letter.
3026 If a path is specified, all components are checked for validity.
3028 @param aParam reference to the variable that on return can contain details of the error if any.
3029 While constructing an object of this type one could specify whether one wants to use the sessionPath for filling up missing parts of aName,
3030 or one would want to test aName as it is without prepending the sessionPath.
3031 By default the sessionPath is NOT used.
3032 1. if the name and optional path in aName are valid, this method will return ETrue and TError::iError will contain ErrNone.
3033 2. if there is an illegal character in aName, this method will return EFalse and TError::iError will contain KErrBadCharacter.
3034 Also TError::iInvalidCharPos will indicate the position of the rightmost invalid character.
3035 3. if there is no illegal characters in aName, but this is still not a valid name (like "")
3036 this method will return EFalse and TError::iError will contain KErrBadCharacter, while iInvalidCharPos will be set to 0
3037 4. if length of the name exceeds 256 characters, this method will return EFalse and TError::iError will contain KErrTooLong.
3038 if the optional sessionPath is used, then the length of the sessionPath is also used to determine whether the length exceeds 256 characters.
3039 @return ETrue, if the name is valid (conforms to the mentioned above criteria); EFalse otherwise.
3041 EFSRV_EXPORT_C TBool RFs::IsValidName(const TDesC& aName, TNameValidParam& aParam )
3043 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName3, MODULEUID, Handle(), aName);
3044 TPckg<TNameValidParam> paramPckg(aParam);
3046 if (SendReceive(EFsIsValidName,TIpcArgs(&aName,NULL,NULL,¶mPckg))!=KErrNone)
3050 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsIsValidName3Return, MODULEUID, b, aParam.ErrorCode());
3057 EFSRV_EXPORT_C TInt RFs::GetDriveName(TInt aDrive,TDes& aDriveName) const
3059 Gets the name of a drive.
3061 Drive naming is optional. If the drive specified has not been assigned a name,
3062 this function returns a descriptor whose length is zero.
3064 @param aDrive The drive number. Specify a drive in the range
3065 EDriveA to EDriveZ for drives A to Z, respectively.
3066 The default drive is the session default drive represented
3068 @param aDriveName On return, the drive name.
3070 @return KErrNone if successful, otherwise one of the other
3071 system-wide error codes.
3076 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsGetDriveName, MODULEUID, Handle(), aDrive);
3077 TInt r = SendReceive(EFsGetDriveName,TIpcArgs(aDrive,&aDriveName));
3079 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsGetDriveNameReturn, MODULEUID, r, aDriveName);
3086 EFSRV_EXPORT_C TInt RFs::SetDriveName(TInt aDrive,const TDesC& aDriveName)
3088 Sets the name of a drive.
3090 Drive naming is optional. Any drive can be assigned a name, and more than
3091 one drive can share the same name.
3093 @param aDrive The drive number. Specify a drive in the range
3094 EDriveA to EDriveZ for drives A to Z, respectively.
3095 Specify KDefaultDrive for the session default drive.
3096 @param aDriveName The name of the drive, with a maximum of 256 characters.
3097 The name cannot contain the 6 characters < > : " / |
3099 @return KErrNone if successful;
3100 KErrBadName, if the name contains illegal characters;
3101 otherwise one of the other system-wide error codes.
3103 @capability DiskAdmin
3107 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsSetDriveName, MODULEUID, Handle(), aDrive, aDriveName);
3108 TInt r = SendReceive(EFsSetDriveName,TIpcArgs(aDrive,&aDriveName));
3110 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetDriveNameReturn, MODULEUID, r);
3117 EFSRV_EXPORT_C TInt RFs::LockDrive(TInt aDrv, const TMediaPassword &aOld, const TMediaPassword &aNew, TBool aStore)
3119 Sets the password for the media in the specified drive.
3121 The media is not necessarily locked afterwards. Accessibility is determined
3122 by the following rules:
3124 - The media may not become locked until power is removed (such as with MMC cards)
3125 - If the password is added to the password store (the aStore parameter is ETrue), the
3126 media will be automatically unlocked on the next access.
3128 @param aDrv The drive.
3129 @param aOld The existing password. If no password is set, this must be a zero-length descriptor.
3130 @param aNew The new password.
3131 @param aStore ETrue if the new password is to be saved to the controller password store;
3134 @return KErrNone if successful;
3135 KErrNotSupported if the media does not support password locking.
3137 @capability DiskAdmin
3141 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsLockDrive, MODULEUID, Handle(), aDrv, aStore);
3142 TInt r = SendReceive(EFsLockDrive,TIpcArgs(aDrv,&aOld,&aNew,aStore));
3144 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsLockDriveReturn, MODULEUID, r);
3151 EFSRV_EXPORT_C TInt RFs::UnlockDrive(TInt aDrive, const TMediaPassword &aPassword, TBool aStore)
3153 Unlocks the media in the specified drive.
3155 The password must be added to the MultiMedia card controller's password store
3156 so that the controller can subsequently issue the password without the user
3157 having to be prompted for it again.
3159 @param aDrive The drive.
3160 @param aPassword The password.
3161 @param aStore Specify ETrue to add the password to the
3162 controller's password store.
3164 @return KErrNone, if successful;
3165 KErrAccessDenied, if the password is incorrect;
3166 KErrAlreadyExists, if the card has already been unlocked;
3167 KErrNotSupported, if the media does not support password locking.
3169 @capability DiskAdmin
3173 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsUnlockDrive, MODULEUID, Handle(), aDrive, aStore);
3174 TInt r = SendReceive(EFsUnlockDrive,TIpcArgs(aDrive,&aPassword,aStore));
3176 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsUnlockDriveReturn, MODULEUID, r);
3183 EFSRV_EXPORT_C TInt RFs::ClearPassword(TInt aDrv, const TMediaPassword &aPswd)
3185 Clears the password from the locked MultiMedia card in the specified drive.
3187 Clearing the password causes the MultiMedia card controller to set
3188 the password to null.
3190 @param aDrv The drive.
3191 @param aPswd The current password, which is required to perform this
3194 @return KErrNone, if successful;
3195 KErrAccessDenied, if the password is wrong or the card is still locked;
3196 otherwise one of the other system-wide error codes.
3198 @capability DiskAdmin
3202 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsClearPassword, MODULEUID, Handle(), aDrv);
3203 TInt r = SendReceive(EFsClearPassword,TIpcArgs(aDrv,&aPswd));
3205 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsClearPasswordReturn, MODULEUID, r);
3212 EFSRV_EXPORT_C TInt RFs::ErasePassword(TInt aDrv)
3214 Erase the password from the locked MultiMedia card in the specified drive.
3216 Used when the password is unknown, and may result in the media being erased.
3218 Successful execution of this call may result in leaving the media in unformatted state.
3219 Hence, it is recommended to format the Multimedia card after calling RFs::ErasePassword().
3221 @param aDrv The drive.
3223 @return KErrNone, if successful;
3224 otherwise one of the other system-wide error codes.
3226 @capability DiskAdmin
3230 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsErasePassword, MODULEUID, Handle(), aDrv);
3231 TInt r = SendReceive(EFsErasePassword,TIpcArgs(aDrv));
3233 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsErasePasswordReturn, MODULEUID, r);
3240 EFSRV_EXPORT_C void RFs::StartupInitComplete(TRequestStatus& aStat)
3242 Noifies the file server that startup initialisation is complete.
3244 @param aStat Request status object.
3247 // Notify file server that startup initialisation has been completed
3250 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsStartupInitComplete, MODULEUID, Handle(), &aStat);
3251 aStat=KRequestPending;
3252 RSessionBase::SendReceive(EFsStartupInitComplete,aStat);
3254 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsStartupInitCompleteReturn, MODULEUID);
3260 EFSRV_EXPORT_C TInt RFs::SetLocalDriveMapping(const TDesC8& aMapping)
3262 // Set the local drive mapping
3265 TRACEMULT2(UTF::EBorder, UTraceModuleEfsrv::EFsSetLocalDriveMapping, MODULEUID, Handle(), aMapping);
3267 TInt r = SendReceive(EFsSetLocalDriveMapping,TIpcArgs(&aMapping));
3269 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetLocalDriveMappingReturn, MODULEUID, r);
3275 Finalise the given drive. This operation is intended to put the drive into the consistent state when it is
3276 safe to remove it physically or switch the power off.
3278 @param aDriveNo drive number
3279 @param aMode describes the finalisation operation, see RFs::TFinaliseDrvMode enum
3281 @return KErrNone on success,
3282 KErrArgument if the function arguments are invalid
3283 KErrInUse if the drive has opened objects (files, directories etc.) and therefore can not be finalised
3284 KErrCorrupt if the drive is corrupt.
3285 System wide error codes otherwise.
3287 @capability DiskAdmin
3289 EFSRV_EXPORT_C TInt RFs::FinaliseDrive(TInt aDriveNo, TFinaliseDrvMode aMode) const
3291 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsFinaliseDrive, MODULEUID, Handle(), aDriveNo, aMode);
3292 TInt r = SendReceive(EFsFinaliseDrive,TIpcArgs(aDriveNo, (TInt)aMode));
3294 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsFinaliseDriveReturn, MODULEUID, r);
3300 Makes the best effort to finalise all drives in the system.
3301 Effectively calls RFs::FinaliseDrive(..., EFinal_RW) to all present drives in the system. This makes impossible to
3302 analyse the error code if the finalisation of some fails.
3303 It is much better to use RFs::FinaliseDrive(...) specifying concrete drive number and desired finalisation mode.
3305 @return KErrNone, if successful; otherwise one of the other system-wide error codes.
3306 @capability DiskAdmin
3308 EFSRV_EXPORT_C TInt RFs::FinaliseDrives()
3310 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsFinaliseDrives, MODULEUID, Handle());
3312 TDriveList driveList;
3313 TDriveInfo driveInfo;
3315 nRes=DriveList(driveList);
3316 if(nRes != KErrNone)
3318 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsFinaliseDrivesReturn, MODULEUID, nRes);
3319 return nRes; //-- unable to obtain drives list
3322 //-- walk through all drives in the system sending them "Finalise" request
3323 for (TInt i=0; i<KMaxDrives; ++i)
3326 continue; //-- skip unexisting drive
3328 if(Drive(driveInfo, i) != KErrNone)
3329 continue; //-- skip this drive, can't get information about it
3331 const TUint KDrvAttExclude = KDriveAttRom | KDriveAttRedirected; //-- the drive attributes to exlcude from the finalisation
3333 if(driveInfo.iDriveAtt & KDrvAttExclude)
3336 nRes = FinaliseDrive(i, EFinal_RW);
3340 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsFinaliseDrivesReturn, MODULEUID, KErrNone);
3346 EFSRV_EXPORT_C TInt RFs::SwapFileSystem(const TDesC& aOldFileSystemName,const TDesC& aNewFileSystemName,TInt aDrive) const
3348 Dismount aOldFileSystemName and mount aNewFileSystemName in an atomic operation
3350 If swapping in the composite filesystem, and no mounts have been added to it,
3351 then ROFS is added to it by default. The synchronous state of the composite filesystem
3352 will be used in preference to that of the old filesystem when it is mounted.
3354 @param aOldFileSystemName The filesystem name that is currently on the drive.
3355 @param aNewFileSystemName The filesystem name that is to be swapped onto the drive.
3356 @param aDrive The drive for which the filesystem is to be swapped.
3358 @return KErrNone if successful
3359 KErrInUse if a dismount is pending on the drive
3360 KErrNotSupported if swapping Z drive with something other then composite or if the drive is asynchronous
3361 KErrAlreadyExists if swapping the composite filesystem, and it is already mounted
3362 KErrNotFound If the filesystem name provided could not be found.
3364 @capability DiskAdmin
3367 TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFsSwapFileSystem, MODULEUID, Handle(), aOldFileSystemName, aNewFileSystemName, aDrive);
3368 TInt r = SendReceive(EFsSwapFileSystem,TIpcArgs(&aNewFileSystemName,aDrive,&aOldFileSystemName));
3370 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSwapFileSystemReturn, MODULEUID, r);
3375 EFSRV_EXPORT_C TInt RFs::AddCompositeMount(const TDesC& aFileSystemName,TInt aLocalDriveToMount,TInt aCompositeDrive, TBool aSync) const
3377 Adds a local drive to the composite filesystem. This can only be used before
3378 the composite filesystem is mounted. The local drive is mounted with the
3379 filesystem provided. If any local drive added is marked to be asynchronous,
3380 then the whole composite drive will be treated asynchronous.
3382 @param aFileSystemName The filesystem of the local drive to be added.
3383 @param aLocalDriveToMount The local drive to be added.
3384 @param aCompositeDrive The drive the composite filesystem will be mounted on.
3385 @param aSync If the filesystem added here is preferred to be synchronous.
3387 @return KErrNone if successful
3388 KErrNotFound If the filesystem name provided could not be found.
3389 KErrNotReady If the composite filesystem has not been initialised.
3390 KErrNotSupported If the composite filesystem is already mounted or the parameters passed are unsupported
3392 @capability DiskAdmin
3395 TRACEMULT5(UTF::EBorder, UTraceModuleEfsrv::EFsAddCompositeMount, MODULEUID,
3396 Handle(), aFileSystemName, aLocalDriveToMount, aCompositeDrive, aSync);
3397 TInt r = SendReceive(EFsAddCompositeMount,TIpcArgs(&aFileSystemName,aLocalDriveToMount,aCompositeDrive,aSync));
3399 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsAddCompositeMountReturn, MODULEUID, r);
3404 EFSRV_EXPORT_C TInt RFs::ReserveDriveSpace(TInt aDriveNo, TInt aSpace)
3406 Reserves an area of a drive. It is intended that sensible (tm) apps will reserve a small
3407 area of disk for 'emergency' use in case of later out of disk situations. If the amount of
3408 reserved space later needs to be readjusted, this method should be called again with
3409 aSpace as the amount of extra space needed.
3411 Once space has been reserved via this method, an application can use RFs::GetReserveAccess
3412 to gain access to the reserved area prior to executing disk space critical sections of code.
3413 After the section of code is complete, the application should release access to the reserved
3416 For internal drives, reserved space will be lost if a reboot occurs. For removeable drives,
3417 reserved space may be lost if there is a media change.
3419 Reserved space will be cleaned up automatically when the RFs is closed.
3421 Each drive has a max amount of space available to be reserved, and individual sessions also
3422 have a max amount of space. These are defined in f32/sfile/sf_std.h as KMaxTotalDriveReserved
3423 and KMaxSessionDriveReserved respectively. Once space is reserved, it is only available to
3424 the reserving session until that session releases the reserved space.
3426 @param aDriveNo Which drive to reserve space on
3428 @param aSpace Amount of space to reserve
3430 @return KErrNone if successful
3431 KErrInUse if the session already has reserved access
3432 KErrArgument if aSpace is invalid (greater than KMaxSessionDriveReserved, negative number, etc.)
3433 KErrDiskFull if insufficient space is left on the drive to service the request
3434 KErrTooBig if this request would overflow the available reserve (greater than KMaxTotalDriveReserved)
3435 any of the possible error return codes from TDrive::Volume()
3438 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsReserveDriveSpace, MODULEUID, Handle(), aDriveNo, aSpace);
3439 TInt r = SendReceive(EFsReserveDriveSpace, TIpcArgs(aDriveNo, aSpace));
3441 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsReserveDriveSpaceReturn, MODULEUID, r);
3448 EFSRV_EXPORT_C TInt RFs::GetReserveAccess(TInt aDriveNo)
3450 Get exclusive access for this session to overwrite a specific disk area, which has previously
3451 been reserved via RFs::ReserveDriveSpace
3453 @param aDriveNo drive on which to get reserved access
3455 @return KErrNone if successful
3456 KErrPermissionDenied if the drive has no spare reserved space
3459 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsGetReserveAccess, MODULEUID, Handle(), aDriveNo);
3460 TInt r = SendReceive(EFsGetReserveAccess, TIpcArgs(aDriveNo));
3462 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsGetReserveAccessReturn, MODULEUID, r);
3466 EFSRV_EXPORT_C TInt RFs::ReleaseReserveAccess(TInt aDriveNo)
3468 Release exclusive access for this session to overwrite a specific disk area.
3470 @param aDriveNo drive on which to release reserved access
3472 @return KErrNone (always returned)
3476 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsReleaseReserveAccess, MODULEUID, Handle(), aDriveNo);
3477 TInt r = SendReceive(EFsReleaseReserveAccess, TIpcArgs(aDriveNo));
3479 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsReleaseReserveAccessReturn, MODULEUID, r);
3487 Controls file system dismounting on the specified drive, the way of control depends on the parameter TNotifyDismountMode.
3489 This API allows interested parties to:
3490 1. Subscribe for notification of file system dismounting events.
3491 This allows subscribers to commit their data to the media prior to the file system being dismounted.
3492 See TNotifyDismountMode::EFsDismountRegisterClient
3494 2. Make a graceful attempt to dismount the file system by notifying the subscribers about a pending file system dismount
3495 and waiting until all subscribers have finished processing the notification and have signaled that they are ready.
3496 If all clients don't respond in a reasonable time, the dismount request may be cancelled, followed by a forced dismount.
3497 If some client does not subscribe for dismounting notification and keeps handles opened, then after the file system dismounting all these
3498 handles will become invalid, any subsequent attempts to use them will result in KErrDismounted, and they should be closed(e.g. RFile::Close()).
3499 See TNotifyDismountMode::EFsDismountNotifyClients
3501 3. Dismount the file system by force even if there are opened handles (files, directories) on the volume being dismounted.
3502 Any clients that kept handles opened, after forced file system dismounting will have them invalidated. And any further attempts to use
3503 these handles will result in KErrDismounted, and they should be closed(e.g. RFile::Close()).
3504 See TNotifyDismountMode::EFsDismountForceDismount
3506 * If there are clamped files on the volume, the file system dismounting will not happen until these files are unclamped.
3509 The use case scenario:
3510 A 'Master' application that wants to dismount the file system on some drive 'aDrive'
3511 'Client1' and 'Client2' applications interested in file system dismount event notifications, because they need to commit their data before the file system is dismounted.
3513 1. 'Client1' and 'Client2' subscribe to the FS dismount notification using EFsDismountRegisterClient and start waiting on the request status objects.
3514 2. 'Master' decides to dismount the file system on the drive 'aDrive'.
3515 2.1 Graceful attempt: 'Master' calls RFs::NotifyDismount() with EFsDismountNotifyClients and starts waiting on 'aStat' for some time until all 'Client1' and 'Client2' respond or timeout occurs.
3517 3. 'Client1' and 'Client2' have their 'aStat' completed as the result of the 'Master' calling EFsDismountNotifyClients.
3518 3.1 'Client1' and 'Client2' flush data and close file handles.
3519 3.2 as soon as 'Client1' and 'Client2' decide that they are ready for the pending FS dismount, they signal the 'Master' that they are ready by calling RFs::AllowDismount()
3521 4. As soon as _all_ subscribed clients ('Client1' and 'Client2') have called RFs::AllowDismount(), the file system on drive 'aDrive' is
3522 dismounted and 'Master' has 'aStat' completed.
3524 If, for example, 'Client2' hasn't responded in a reasonable time by calling RFs::AllowDismount(), the 'Master' can cancel the pending 'aStat' and
3525 dismount the file system by force by calling this API with EFsDismountForceDismount.
3526 In this case all subsequent attempts by 'Client2' to use its opened handles will result in KErrDismounted; these handles should be closed.
3530 @param aDriveNo The drive on which to request dismount
3531 @param aMode specifies the behaviour of the notification API
3532 @param aStat Asynchronous request state.
3534 EFSRV_EXPORT_C void RFs::NotifyDismount(TInt aDrive, TRequestStatus& aStat, TNotifyDismountMode aMode /*=EFsDismountRegisterClient*/) const
3536 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismount, MODULEUID, Handle(), aDrive, &aStat, aMode);
3537 aStat = KRequestPending;
3538 RSessionBase::SendReceive(EFsNotifyDismount, TIpcArgs(aDrive,aMode,&aStat), aStat);
3539 // This call is to synchronise with the driver thread as the corresponding cancel function (NotifyDismountCancel)
3540 // is synchronous, so it can complete before this notify request has even been added to TDismountNotifyQue.
3541 // This call guarantees that the notify request has been added to queue.
3542 SendReceive(EFsSynchroniseDriveThread, TIpcArgs(aDrive));
3544 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismountReturn, MODULEUID);
3551 Cancels the oustanding dismount notifier, completing with KErrCancel.
3553 @param aStat The request status object associated with the request to be cancelled.
3555 @see RFs::NotifyDismount
3557 EFSRV_EXPORT_C void RFs::NotifyDismountCancel(TRequestStatus& aStat) const
3559 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismountCancel1, MODULEUID, Handle(), &aStat);
3561 if (aStat == KRequestPending)
3562 SendReceive(EFsNotifyDismountCancel, TIpcArgs(&aStat));
3564 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismountCancel1Return, MODULEUID);
3570 Cancels all oustanding dismount notifiers for this session, completing with KErrCancel.
3572 @see RFs::NotifyDismount
3574 EFSRV_EXPORT_C void RFs::NotifyDismountCancel() const
3576 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismountCancel2, MODULEUID, Handle());
3578 SendReceive(EFsNotifyDismountCancel, TIpcArgs(NULL));
3580 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsNotifyDismountCancel2Return, MODULEUID);
3587 Used by a client to indicate that it is safe to dismount the file system. This should be called after receiving a pending media removal notification.
3589 Not calling this does not guarantee that the dismount will not occur as the application requesting the dismount may decide to forcibly dismount
3590 after a given timeout period.
3592 @param aDriveNo The drive on which to allow the dismount.
3594 @return KErrNone if successful
3596 @see RFs::NotifyDismount
3598 EFSRV_EXPORT_C TInt RFs::AllowDismount(TInt aDrive) const
3600 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsAllowDismount, MODULEUID, Handle(), aDrive);
3601 TInt r = SendReceive(EFsAllowDismount, TIpcArgs(aDrive));
3603 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsAllowDismountReturn, MODULEUID, r);
3607 EFSRV_EXPORT_C TInt RFs::SetStartupConfiguration(TInt aCommand,TAny* aParam1,TAny* aParam2) const
3612 Only can be called in estart. Licensees could use this function to configure
3613 file server at startup through their own version of estart.
3615 Currently only loader thread priority can be specified.
3617 @param aCommand Command indicating what aspect of file server should be configured.
3618 aParam1 Command specific parameter.
3619 aParam2 Command specific parameter.
3621 @return KErrNone if successful, KErrPermissionDenied if called outside estart
3624 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFsSetStartupConfiguration, MODULEUID, Handle(), aCommand, aParam1, aParam2);
3625 TInt r = SendReceive(EFsSetStartupConfiguration, TIpcArgs(aCommand,aParam1,aParam2));
3627 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetStartupConfigurationReturn, MODULEUID, r);
3632 EFSRV_EXPORT_C TInt RFs::SetNotifyChange(TBool aNotifyChange)
3634 Enables/Disables change notification on a per-session basis. Change notification is enabled
3635 by default, and can be disabled using this API. Disabling change notification will result in
3636 clients of the file server not being notified of events such as directory/file changes.
3638 @param aNotifyChange ETrue to enable change notifications, EFalse to disable.
3640 @return KErrNone if successful.
3642 @capability DiskAdmin
3644 @see RFs::NotifyChange
3647 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsSetNotifyChange, MODULEUID, Handle(), aNotifyChange);
3648 TInt r = SendReceive(EFsSetSessionFlags, TIpcArgs(aNotifyChange ? EFsSessionNotifyChange: 0, aNotifyChange ? 0 : EFsSessionNotifyChange));
3650 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsSetNotifyChangeReturn, MODULEUID, r);
3655 TInt RFs::Unclamp(const RFileClamp& aHandle)
3657 Makes available for paging-out the media space occupied by the file identified by
3658 the supplied handle.
3660 @param aHandle handle to the file on the media.
3662 @return KErrNone if successful.
3669 TPckg<RFileClamp> pkHandle(aHandle);
3670 return SendReceive(EFsUnclamp, TIpcArgs(& pkHandle));
3673 EFSRV_EXPORT_C TInt RFs::InitialisePropertiesFile(const TPtrC8& aPtr) const
3675 Sets the F32 properties file - Can only be called from the ESTART process
3677 @param aPtr A descriptor pointing to an INI file in ROM.
3679 @return KErrNone if successful.
3681 @capability KDiskAdmin
3684 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsInitialisePropertiesFile, MODULEUID, Handle(), aPtr.Ptr(), aPtr.Length());
3685 TInt r = SendReceive(EFsInitialisePropertiesFile, TIpcArgs(aPtr.Ptr(), aPtr.Length(), ETrue));
3687 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsInitialisePropertiesFileReturn, MODULEUID, r);
3691 EFSRV_EXPORT_C TInt RFs::QueryVolumeInfoExt(TInt aDrive, TQueryVolumeInfoExtCmd aCommand, TDes8& aInfo) const
3694 Queries specific information on volumes by commands. Available commands is defined by TQueryVolumeInfoExtCmd.
3696 @param aDriveNo The drive on which to query information.
3697 @param aCommand A command to specify which information is under query
3698 @param aInfo A TPckgBuf<> to carry returned results.
3700 @return KErrNone if successful; otherwise another system-wide error code is returned.
3702 @see TQueryVolumeInfoExtCmd
3703 @see TVolumeIOParamInfo
3706 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFsQueryVolumeInfoExt, MODULEUID, Handle(), aDrive, aCommand);
3707 TInt r = SendReceive(EFsQueryVolumeInfoExt, TIpcArgs(aDrive, aCommand, &aInfo));
3709 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsQueryVolumeInfoExtReturn, MODULEUID, r);
3714 EFSRV_EXPORT_C TInt RFs::VolumeIOParam(TInt aDrive, TVolumeIOParamInfo& aParamInfo) const
3716 This function queries a set of I/O parameters on the specified volume, this includes the block size of underlying media,
3717 cluster size of the mounted file system and the recommended read/write buffer sizes.
3719 The volume information is retuned through aParamInfo. Even if VolumeIOParam() returns successful, errors
3720 can effect the return value of each field within aParamInfo.
3722 @param aDrive A drive number, specifies which volume to query.
3723 @param aParamInfo A TVolumeIOParamInfo containing the volume parameters.
3725 @return KErrNone if successful; otherwise, another system wide error code is returned.
3728 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFsVolumeIOParam, MODULEUID, Handle(), aDrive);
3732 if (!IsValidDrive(aDrive))
3737 TPckgBuf<TVolumeIOParamInfo> infoPckg;
3738 r = QueryVolumeInfoExt(aDrive, EIOParamInfo, infoPckg);
3740 aParamInfo = infoPckg();
3743 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFsVolumeIOParamReturn, MODULEUID,
3744 r, aParamInfo.iBlockSize, aParamInfo.iClusterSize, aParamInfo.iRecReadBufSize, aParamInfo.iRecWriteBufSize);
3750 This function queries the sub type of the file system mounted on the specified volume. For example, 'FAT16' of the Fat file system.
3751 TFSName is recommended as the type for aName when using this function.
3753 NOTE: For the file systems without a sub type (e.g. ROM file system), the the file system name is returned (For example, 'Rom').
3755 "FAT" file system; the subtypes can be "fat12", "fat16" or "fat32"
3756 "ROFS" file system; the subtype will be "ROFS"
3758 Note also that the file system name, returned in the aName descriptor shall be threated as case-insensitive string. I.e.
3759 "fileSystem" and "FILESYSTEM" mean absolutely the same. Therefore, case-insensitive string methods (like TDesC::FindF(), TDesC::CompareF())
3760 shall be used to deal with the names.
3763 @param aDrive drive number, specifies which volume to query.
3764 @param aName descriptor containing the returned sub type name or file system name.
3766 @return KErrNone if successful; KErrNotSuppoted if sub type is not supported;
3767 otherwise another system-wide error code is returned.
3771 EFSRV_EXPORT_C TInt RFs::FileSystemSubType(TInt aDrive, TDes& aName) const
3773 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemSubType, MODULEUID, Handle(), aDrive, aName);
3777 if (!IsValidDrive(aDrive))
3782 TPckgBuf<TFSName> namePckg;
3783 r = QueryVolumeInfoExt(aDrive, EFileSystemSubType, namePckg);
3784 if (r == KErrNone || r == KErrNotSupported)
3788 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFsFileSystemSubTypeReturn, MODULEUID, r);
3792 EXPORT_C TInt RFs::AddProxyDrive(const TDesC& aFileName)
3794 Loads the specified extension.
3796 @param aFileName The file name of the extension
3798 @return KErrNone, if successful; otherwise one of the other system wide error codes.
3802 TInt r = loader.Connect();
3805 r = loader.SendReceive(ELoadFSProxyDrive, TIpcArgs(0, &aFileName, 0));
3812 EXPORT_C TInt RFs::RemoveProxyDrive(const TDesC& aExtensionName)
3814 Removes the specified extension.
3816 @param aExtensionName The fullname of the extension, as returned from
3817 a call to ExtensionName().
3819 @return KErrNone, if successful;
3820 KErrInUse if there are still drives mounted that are using it
3821 KErrNotFound, if aExtensionName is not found;
3822 otherwise one of the other system-wide error codes.
3825 return(SendReceive(EFsRemoveProxyDrive,TIpcArgs(&aExtensionName)));
3829 Initialises a proxy drive.
3831 @param aProxyDriveNumber drive number that will be used to mount the proxy drive
3832 @param aName name of the proxy drive extension
3833 @param anInfo initialisation information to be passed to the proxy drive extension to initialise the drive
3835 @return If succesful the internal drive number used to represent the drive (equivalent to a local drive
3836 number for normal drives) This number is obtained dynmically. The number will range between KMaxLocalDrives
3838 KErrInUse if aProxyDriveNumber is in use or if there are not proxy drive numbers left
3839 KErrArgument if aProxyDriveNumber or aName are invalid
3840 Any other system wide error code.
3844 EXPORT_C TInt RFs::DoMountProxyDrive(const TIpcArgs& ipcArgs)
3846 return SendReceive(EFsMountProxyDrive, ipcArgs);
3850 EXPORT_C TInt RFs::DismountProxyDrive(const TUint aProxyDriveNumber)
3852 Dismounts a proxy drive.
3854 @param aProxyDriveNumber drive number that will be used to mount the proxy drive
3855 @param aName name of the proxy drive extension
3856 @param anInfo initialisation information to be passed to the proxy drive extension to initialise the drive
3858 @return If succesful the internal drive number used to represent the drive (equivalent to a local drive
3859 number for normal drives) This number is obtained dynmically. The number will range between KMaxLocalDrives
3861 KErrInUse if aProxyDriveNumber is in use or if there are not proxy drive numbers left
3862 KErrArgument if aProxyDriveNumber or aName are invalid
3863 Any other system wide error code.
3868 return SendReceive(EFsDismountProxyDrive,TIpcArgs(aProxyDriveNumber));
3871 EFSRV_EXPORT_C void RFs::Close()
3873 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFsClose, MODULEUID, Handle());
3876 RSessionBase::Close();
3878 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFsCloseReturn, MODULEUID);