13 // Description: |
13 // Description: |
14 // |
14 // |
15 |
15 |
16 #include "SqlSrvFileData.h" |
16 #include "SqlSrvFileData.h" |
17 #include "SqlSrvUtil.h" |
17 #include "SqlSrvUtil.h" |
18 #include "SqlPanic.h" |
18 #include "SqlAssert.h" |
19 #include "SqlSrvStrings.h" |
19 #include "SqlSrvStrings.h" |
20 #include "SqlSrvResourceProfiler.h" |
20 #include "SqlSrvResourceProfiler.h" |
21 |
21 |
22 _LIT(KPrivateFmtStr, "\\private\\%08X\\"); |
22 _LIT(KPrivateFmtStr, "\\private\\%08X\\"); |
23 |
23 |
33 @internalComponent |
33 @internalComponent |
34 */ |
34 */ |
35 static void CreatePrivateDataPathL(RFs& aFs, TDriveNumber aDriveNumber) |
35 static void CreatePrivateDataPathL(RFs& aFs, TDriveNumber aDriveNumber) |
36 { |
36 { |
37 TDriveInfo driveInfo; |
37 TDriveInfo driveInfo; |
38 __SQLLEAVE_IF_ERROR(aFs.Drive(driveInfo, aDriveNumber)); |
38 __SQLLEAVE_IF_ERROR2(aFs.Drive(driveInfo, aDriveNumber)); |
39 if(!(driveInfo.iDriveAtt & KDriveAttRom)) |
39 if(!(driveInfo.iDriveAtt & KDriveAttRom)) |
40 { |
40 { |
41 TInt err = aFs.CreatePrivatePath(aDriveNumber); |
41 TInt err = aFs.CreatePrivatePath(aDriveNumber); |
42 if(err != KErrNone && err != KErrAlreadyExists) |
42 if(err != KErrNone && err != KErrAlreadyExists) |
43 { |
43 { |
44 __SQLLEAVE(err); |
44 __SQLLEAVE2(err); |
45 } |
45 } |
46 } |
46 } |
47 } |
47 } |
48 |
48 |
49 /** |
49 /** |
112 @internalComponent |
112 @internalComponent |
113 */ |
113 */ |
114 static void DoFullFileNameL(TDes& aDbFileName, const TDesC& aSysDrivePrivatePath, TDriveNumber& aDrive) |
114 static void DoFullFileNameL(TDes& aDbFileName, const TDesC& aSysDrivePrivatePath, TDriveNumber& aDrive) |
115 { |
115 { |
116 TParse parse; |
116 TParse parse; |
117 __SQLLEAVE_IF_ERROR(parse.Set(aDbFileName, &aSysDrivePrivatePath, NULL)); |
117 __SQLLEAVE_IF_ERROR2(parse.Set(aDbFileName, &aSysDrivePrivatePath, NULL)); |
118 if(!parse.NamePresent()) |
118 if(!parse.NamePresent()) |
119 { |
119 { |
120 __SQLLEAVE(KErrBadName); |
120 __SQLLEAVE2(KErrBadName); |
121 } |
121 } |
122 aDbFileName.Copy(parse.FullName()); |
122 aDbFileName.Copy(parse.FullName()); |
123 TPtrC driveName = parse.Drive(); |
123 TPtrC driveName = parse.Drive(); |
124 __SQLASSERT(driveName.Length() > 0, ESqlPanicInternalError); |
124 __ASSERT_DEBUG(driveName.Length() > 0, __SQLPANIC2(ESqlPanicInternalError)); |
125 TInt driveNumber = -1; |
125 TInt driveNumber = -1; |
126 __SQLLEAVE_IF_ERROR(RFs::CharToDrive(driveName[0], driveNumber)); |
126 __SQLLEAVE_IF_ERROR2(RFs::CharToDrive(driveName[0], driveNumber)); |
127 aDrive = static_cast <TDriveNumber> (driveNumber); |
127 aDrive = static_cast <TDriveNumber> (driveNumber); |
128 } |
128 } |
129 |
129 |
130 /** |
130 /** |
131 Extracts file name properties, such as secure/non-secure file name, secure UID (SID). |
131 Extracts file name properties, such as secure/non-secure file name, secure UID (SID). |
141 TBool& aIsSecureFileNameFmt, TUid& aSecureUid) |
141 TBool& aIsSecureFileNameFmt, TUid& aSecureUid) |
142 { |
142 { |
143 //If SQL server private path is in the file name - leave |
143 //If SQL server private path is in the file name - leave |
144 if(::IsPrivatePathInFileName(aDbFileName, aServerPrivatePath)) |
144 if(::IsPrivatePathInFileName(aDbFileName, aServerPrivatePath)) |
145 { |
145 { |
146 __SQLLEAVE(KErrArgument); |
146 __SQLLEAVE2(KErrArgument); |
147 } |
147 } |
148 //Extract database SID from the name |
148 //Extract database SID from the name |
149 aIsSecureFileNameFmt = ::IsSecureFileNameFmt(aDbFileName); |
149 aIsSecureFileNameFmt = ::IsSecureFileNameFmt(aDbFileName); |
150 aSecureUid = KNullUid; |
150 aSecureUid = KNullUid; |
151 if(aIsSecureFileNameFmt) |
151 if(aIsSecureFileNameFmt) |
196 #ifdef SQLSRV_STARTUP_TEST |
196 #ifdef SQLSRV_STARTUP_TEST |
197 const TDesC& aDbFileName, |
197 const TDesC& aDbFileName, |
198 #endif |
198 #endif |
199 const TDesC8* aConfigStr) |
199 const TDesC8* aConfigStr) |
200 { |
200 { |
201 __SQLASSERT((TUint)aFileNameArgNum < KMaxMessageArguments, ESqlPanicBadArgument); |
201 __ASSERT_DEBUG((TUint)aFileNameArgNum < KMaxMessageArguments, __SQLPANIC(ESqlPanicBadArgument)); |
202 __SQLASSERT(iSysDrivePrivatePath.DriveAndPath().Length() > 0, ESqlPanicInternalError); |
202 __ASSERT_DEBUG(iSysDrivePrivatePath.DriveAndPath().Length() > 0, __SQLPANIC(ESqlPanicInternalError)); |
203 |
203 |
204 if(aFileNameLen < 1 || aFileNameLen > KMaxFileName) |
204 if(aFileNameLen < 1 || aFileNameLen > KMaxFileName) |
205 { |
205 { |
206 __SQLLEAVE(KErrBadName); |
206 __SQLLEAVE(KErrBadName); |
207 } |
207 } |