File tree Expand file tree Collapse file tree
native/cocos/platform/openharmony Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,6 +183,15 @@ long FileUtilsOpenHarmony::getFileSize(const std::string &filepath) {
183183 return 0 ;
184184 }
185185
186+ if (fullPath[0 ] == ' /' ) {
187+ struct stat info;
188+ int result = stat (fullPath.c_str (), &info);
189+ if (result != 0 ) {
190+ return -1 ;
191+ }
192+ return static_cast <long >(info.st_size );
193+ }
194+
186195 long filesize = 0 ;
187196 RawFile64 *rawFile = OH_ResourceManager_OpenRawFile64 (_nativeResourceManager, fullPath.c_str ());
188197 if (rawFile) {
@@ -201,11 +210,11 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
201210 return false ;
202211 }
203212
204- if (strFilePath[0 ] != ' /' ) {
213+ if (strFilePath[0 ] != ' /' ) {
205214 const char *s = strFilePath.c_str ();
206215 // Found "@assets/" at the beginning of the path and we don't want it
207216 if (strFilePath.find (ASSETS_FOLDER_NAME ) == 0 ) s += strlen (ASSETS_FOLDER_NAME );
208-
217+
209218 if (nullptr == _nativeResourceManager) {
210219 CC_LOG_ERROR (" nativeResourceManager is nullptr" );
211220 return false ;
@@ -217,7 +226,7 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
217226 return true ;
218227 }
219228 return false ;
220- }
229+ }
221230 FILE *fp = fopen (strFilePath.c_str (), " r" );
222231 if (fp) {
223232 fclose (fp);
You can’t perform that action at this time.
0 commit comments