@geastack/host 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/host/image.cpp +14 -5
- package/package.json +1 -1
- package/services/app_state.cpp +8 -0
package/host/image.cpp
CHANGED
|
@@ -133,6 +133,15 @@ bool isAbsoluteFilePath(const char *path) {
|
|
|
133
133
|
#endif
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
// Storage is ready for `path`: an SD-card path needs the card mounted; a path
|
|
137
|
+
// on any other volume (the flash apps volume, /nand, SPIFFS) is read as is, so
|
|
138
|
+
// a board with no card slot still shows images from its own storage.
|
|
139
|
+
bool storageReadyFor(const std::string &path) {
|
|
140
|
+
if (gea::platform::storage::ensureMounted())
|
|
141
|
+
return true;
|
|
142
|
+
return path.compare(0, 7, "/sdcard") != 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
136
145
|
// mkdir -p of the parent directories in `path` (FAT/VFS); existing dirs are
|
|
137
146
|
// fine.
|
|
138
147
|
void makeParentDirs(const std::string &path) {
|
|
@@ -275,7 +284,7 @@ bool ImageService::writeFile(const std::string &path,
|
|
|
275
284
|
bool result = false;
|
|
276
285
|
gea::platform::onInternalStack([&] {
|
|
277
286
|
if (path.empty() || bytes.empty() ||
|
|
278
|
-
!
|
|
287
|
+
!storageReadyFor(path))
|
|
279
288
|
return;
|
|
280
289
|
makeParentDirs(path);
|
|
281
290
|
gea::platform::storage::FileOperations files;
|
|
@@ -287,7 +296,7 @@ bool ImageService::writeFile(const std::string &path,
|
|
|
287
296
|
bool ImageService::removeFile(const std::string &path) const {
|
|
288
297
|
bool result = false;
|
|
289
298
|
gea::platform::onInternalStack([&] {
|
|
290
|
-
if (!path.empty() &&
|
|
299
|
+
if (!path.empty() && storageReadyFor(path))
|
|
291
300
|
result = std::remove(path.c_str()) == 0;
|
|
292
301
|
});
|
|
293
302
|
return result;
|
|
@@ -297,7 +306,7 @@ std::vector<std::uint8_t>
|
|
|
297
306
|
ImageService::readFile(const std::string &path) const {
|
|
298
307
|
std::vector<std::uint8_t> result;
|
|
299
308
|
gea::platform::onInternalStack([&] {
|
|
300
|
-
if (!path.empty() &&
|
|
309
|
+
if (!path.empty() && storageReadyFor(path))
|
|
301
310
|
result = readWholeFile(path);
|
|
302
311
|
});
|
|
303
312
|
return result;
|
|
@@ -321,7 +330,7 @@ std::vector<std::uint8_t> ImageService::readFileRange(const std::string &path,
|
|
|
321
330
|
std::vector<std::uint8_t> out;
|
|
322
331
|
gea::platform::onInternalStack([&] {
|
|
323
332
|
if (path.empty() || offset < 0 || length <= 0 ||
|
|
324
|
-
!
|
|
333
|
+
!storageReadyFor(path))
|
|
325
334
|
return;
|
|
326
335
|
std::FILE *f = gea::platform::storage::openRead(path);
|
|
327
336
|
if (!f)
|
|
@@ -338,7 +347,7 @@ std::vector<std::uint8_t> ImageService::readFileRange(const std::string &path,
|
|
|
338
347
|
std::string ImageService::listFiles(const std::string &path) const {
|
|
339
348
|
std::string out;
|
|
340
349
|
gea::platform::onInternalStack([&] {
|
|
341
|
-
if (path.empty() || !
|
|
350
|
+
if (path.empty() || !storageReadyFor(path))
|
|
342
351
|
return;
|
|
343
352
|
#ifdef GEA_HOST_HAS_DIRENT
|
|
344
353
|
DIR *dir = opendir(path.c_str());
|
package/package.json
CHANGED
package/services/app_state.cpp
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#include "services/app_state.h"
|
|
3
3
|
|
|
4
|
+
#if GEA_GEAOS
|
|
4
5
|
#include "geaos.h"
|
|
6
|
+
#endif
|
|
5
7
|
#include "services/mirror.h"
|
|
6
8
|
|
|
7
9
|
namespace gea::framework::services {
|
|
8
10
|
|
|
11
|
+
// Under GeaOS the launcher knows which installed app is running. A single app
|
|
12
|
+
// is the only program there is and never changes, so there is nothing to name.
|
|
9
13
|
const char *AppState::currentAppId()
|
|
10
14
|
{
|
|
15
|
+
#if GEA_GEAOS
|
|
11
16
|
return gea::geaos::Launcher::currentId();
|
|
17
|
+
#else
|
|
18
|
+
return "";
|
|
19
|
+
#endif
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
void AppState::afterAppInit()
|