File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ class HippyFile {
5151 static int CreateDir (const string_view& dir_path, mode_t mode);
5252 static int CheckDir (const string_view& dir_path, int mode);
5353 static uint64_t GetFileModifyTime (const string_view& file_path);
54+ static const char * RemoveFilePrefix (const char * str);
5455
5556 template <typename CharType>
5657 static bool ReadFile (const string_view& file_path,
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ uint64_t HippyFile::GetFileModifyTime(const string_view& file_path) {
124124 auto path_str = StringViewUtils::ConvertEncoding (file_path,
125125 string_view::Encoding::Utf8).utf8_value ();
126126 auto path = reinterpret_cast <const char *>(path_str.c_str ());
127+ path = RemoveFilePrefix (path);
127128 struct stat statInfo{};
128129 FILE* fp = fopen (path, " r" );
129130 if (fp == nullptr ) {
@@ -139,5 +140,16 @@ uint64_t HippyFile::GetFileModifyTime(const string_view& file_path) {
139140 return modify_time;
140141}
141142
143+ const char * HippyFile::RemoveFilePrefix (const char * str) {
144+ const char * prefix = " file:" ;
145+ size_t prefix_len = strlen (prefix);
146+
147+ if (strncmp (str, prefix, prefix_len) == 0 ) {
148+ return str + prefix_len;
149+ }
150+
151+ return str;
152+ }
153+
142154} // namespace vfs
143155} // namespace hippy
You can’t perform that action at this time.
0 commit comments