equal
deleted
inserted
replaced
33 #include <QFileInfo> |
33 #include <QFileInfo> |
34 #include <hbfindfile.h> |
34 #include <hbfindfile.h> |
35 #include <qbasicatomic.h> |
35 #include <qbasicatomic.h> |
36 #include <QDir> |
36 #include <QDir> |
37 |
37 |
|
38 #ifdef Q_OS_SYMBIAN |
|
39 /*! |
|
40 Convert path to Symbian version |
|
41 */ |
|
42 static void toSymbianPath(QString &path) { |
|
43 int len=path.length(); |
|
44 for (int i=0; i<len; i++) { |
|
45 QCharRef ref=path[i]; |
|
46 if (ref == '/') { |
|
47 ref= '\\'; |
|
48 } |
|
49 } |
|
50 } |
|
51 #endif |
|
52 |
38 /*! |
53 /*! |
39 @beta |
54 @beta |
40 @hbcore |
55 @hbcore |
41 \class HbFindFile |
56 \class HbFindFile |
42 \brief Checks from which drive a certain file is found. |
57 \brief Checks from which drive a certain file is found. |
52 bool HbFindFile::hbFindFile(QString &str, const QChar &defaultDrive) |
67 bool HbFindFile::hbFindFile(QString &str, const QChar &defaultDrive) |
53 { |
68 { |
54 #ifdef Q_OS_SYMBIAN |
69 #ifdef Q_OS_SYMBIAN |
55 RFs& fs = CCoeEnv::Static()->FsSession(); |
70 RFs& fs = CCoeEnv::Static()->FsSession(); |
56 TFindFile ff(fs); |
71 TFindFile ff(fs); |
57 TPtrC fName((ushort*)(str.constData()),str.length()); |
72 QString str2 = str; |
|
73 toSymbianPath(str2); |
|
74 TPtrC fName((ushort*)(str2.constData()),str2.length()); |
58 QString dNameString; |
75 QString dNameString; |
59 |
76 |
60 if (!defaultDrive.isNull()) { |
77 if (!defaultDrive.isNull()) { |
61 dNameString.append(defaultDrive); |
78 dNameString.append(defaultDrive); |
62 dNameString += QString(":"); |
79 dNameString += QString(":"); |
66 TInt err=ff.FindByDir(fName, dName); |
83 TInt err=ff.FindByDir(fName, dName); |
67 if (err==KErrNone) { |
84 if (err==KErrNone) { |
68 TParse p; |
85 TParse p; |
69 p.Set(ff.File(), 0,0); |
86 p.Set(ff.File(), 0,0); |
70 TPtrC ptrC = p.Drive(); |
87 TPtrC ptrC = p.Drive(); |
71 QString str2 = QString::fromRawData((QChar*)(ushort*)ptrC.Ptr(),ptrC.Length()); |
88 QString str3 = QString::fromRawData((QChar*)(ushort*)ptrC.Ptr(),ptrC.Length()); |
72 str.prepend(str2); |
89 str.prepend(str3); |
73 return true; |
90 return true; |
74 } |
91 } |
75 else { |
92 else { |
76 return false; |
93 return false; |
77 } |
94 } |
101 return false; |
118 return false; |
102 #endif |
119 #endif |
103 |
120 |
104 } |
121 } |
105 |
122 |
|
123 /*! |
|
124 Helper class |
|
125 */ |
106 class AvailableDrives : public QString |
126 class AvailableDrives : public QString |
107 { |
127 { |
108 public: |
128 public: |
109 AvailableDrives(); |
129 AvailableDrives(); |
110 }; |
130 }; |
111 |
131 |
|
132 /*! |
|
133 Search available drives |
|
134 */ |
112 AvailableDrives::AvailableDrives() { |
135 AvailableDrives::AvailableDrives() { |
113 #ifdef Q_OS_SYMBIAN |
136 #ifdef Q_OS_SYMBIAN |
114 RFs& fs = CCoeEnv::Static()->FsSession(); |
137 RFs& fs = CCoeEnv::Static()->FsSession(); |
115 TDriveList driveList; |
138 TDriveList driveList; |
116 fs.DriveList(driveList); |
139 fs.DriveList(driveList); |
122 driveNumber = EDriveC; |
145 driveNumber = EDriveC; |
123 fs.DriveToChar(driveNumber, driveLetter); |
146 fs.DriveToChar(driveNumber, driveLetter); |
124 QChar cC = static_cast<QChar>(driveLetter); |
147 QChar cC = static_cast<QChar>(driveLetter); |
125 this->append(cC); |
148 this->append(cC); |
126 } |
149 } |
127 for (driveNumber = EDriveY; driveNumber >= EDriveA; driveNumber--) { |
150 for (driveNumber = EDriveY; driveNumber >= EDriveA; --driveNumber) { |
128 if (driveNumber == EDriveC) { |
151 if (driveNumber == EDriveC) { |
129 continue; |
152 continue; |
130 } |
153 } |
131 else { |
154 else { |
132 if (driveList[driveNumber]) { |
155 if (driveList[driveNumber]) { |