| 166 | } |
| 167 | |
| 168 | bool JsonAssetBase::Save(const StringView& path) |
| 169 | { |
| 170 | if (OnCheckSave(path)) |
| 171 | return true; |
| 172 | PROFILE_CPU(); |
| 173 | ScopeLock lock(Locker); |
| 174 | |
| 175 | // Serialize to json to the buffer |
| 176 | rapidjson_flax::StringBuffer buffer; |
| 177 | PrettyJsonWriter writerObj(buffer); |
| 178 | _isResaving = true; |
| 179 | saveInternal(writerObj); |
| 180 | _isResaving = false; |
| 181 | |
| 182 | // Save json to file |
| 183 | if (File::WriteAllBytes(path.HasChars() ? path : GetPath(), (byte*)buffer.GetString(), (int32)buffer.GetSize())) |
| 184 | { |
| 185 | LOG(Error, "Cannot save \'{0}\'", ToString()); |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | bool JsonAssetBase::Save(JsonWriter& writer) const |
| 193 | { |