Skip to content

Commit ff9f3a0

Browse files
committed
Folder import / export is working again
1 parent ceea04e commit ff9f3a0

File tree

14 files changed

+57
-46
lines changed

14 files changed

+57
-46
lines changed

Core/FileSystems/FSBlock.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ FSBlock::relName(const FSBlock &top) const
212212

213213
for (auto &it : nodes) {
214214

215+
if (it == &top) break;
215216
auto name = it->pathName();
216217
result = name + "/" + result;
217-
if (it == &top) break;
218218
}
219219

220220
return util::trim(result, "/");
@@ -227,6 +227,9 @@ FSBlock::sanitizedPath() const
227227

228228
auto nodes = fs->collect(*this, [](auto *node) { return node->getParentDirBlock(); });
229229

230+
// Delete the root node
231+
if (!nodes.empty()) nodes.pop_back();
232+
230233
for (auto &it : nodes) {
231234

232235
auto name = it->getName().path();

Core/FileSystems/FSBlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ inline std::function<bool(const FSBlock &, const FSBlock &)> dafa = [](const FSB
384384

385385
if ( b1.isDirectory() && !b2.isDirectory()) return true;
386386
if (!b1.isDirectory() && b2.isDirectory()) return false;
387-
return b1.pathName() < b2.pathName();
387+
return b1.getName() < b2.getName();
388388
};
389389

390390
inline std::function<bool(const FSBlock &, const FSBlock &)> alpha = [](const FSBlock &b1, const FSBlock &b2) {
391391

392-
return b1.pathName() < b2.pathName();
392+
return b1.getName() < b2.getName();
393393
};
394394

395395
inline std::function<bool(const FSBlock &, const FSBlock &)> none = nullptr;

Core/FileSystems/FSStorage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ FSStorage::_dump(Category category, std::ostream &os) const
5151

5252
case Category::Blocks:
5353

54-
os << tab("Capacity") << numBlocks() << " blocks" << std::endl;
55-
os << tab("Block size") << bsize << " bytes" << std::endl;
54+
os << tab("Capacity") << numBlocks() << " blocks (x " << bsize << " bytes)" << std::endl;
5655
os << tab("Hashed blocks") << blocks.size() << std::endl;
5756
break;
5857

Core/FileSystems/FSTree.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct FSTree {
3535

3636
// Traverses the tree and applies a function at each node
3737
void bfsWalk(std::function<void(const FSTree &)>);
38+
void bfsWalkRec(std::function<void(const FSTree &)>);
3839
void dfsWalk(std::function<void(const FSTree &)>);
3940

4041
void sort(std::function<bool(const FSBlock &,const FSBlock &)>);
@@ -45,9 +46,6 @@ struct FSTree {
4546

4647
private:
4748

48-
49-
void bfsWalkRec(std::function<void(const FSTree &)>);
50-
5149
void listRec(std::ostream &os, const FSOpt &opt) const;
5250
void listItems(std::ostream &os, const FSOpt &opt) const;
5351
};

Core/FileSystems/MutableFileSystem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MutableFileSystem::init(const FSDescriptor &layout, const fs::path &path)
5555
if (!path.empty()) {
5656

5757
// Add all files
58-
import(root(), path);
58+
import(root(), path, true, true);
5959

6060
// Assign device name
6161
setName(FSName(path.filename().string()));
@@ -862,7 +862,8 @@ MutableFileSystem::exportDirectory(const fs::path &path, bool createDir) const
862862
auto tree = FSTree(root(), { .recursive = true });
863863

864864
// Export all items
865-
tree.bfsWalk([&](const FSTree &t) {
865+
tree.bfsWalkRec([&](const FSTree &t) {
866+
printf("Node: %s\n", t.node->relName(root()).c_str());
866867
if (Fault error = t.node->exportBlock(path.c_str()); error != Fault::OK) {
867868
throw AppError(error);
868869
}

Core/FileSystems/MutableFileSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MutableFileSystem : public FileSystem {
173173

174174
public:
175175

176-
// Imports the volume from a buffer compatible with the ADF format
176+
// Imports the volume from a buffer compatible with the ADF or HDF format
177177
void importVolume(const u8 *src, isize size) throws;
178178

179179
// Imports files and folders from the host file system

Core/Misc/RetroShell/Console.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class Console : public SubComponent {
9090

9191
// History buffer storing old input strings and cursor positions
9292
std::vector<std::pair<string,isize>> history;
93-
9493
// The currently active input string
9594
isize ipos = 0;
9695

Core/Misc/RetroShell/DebuggerConsole.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ namespace vamiga {
1616
void
1717
DebuggerConsole::_pause()
1818
{
19-
*this << '\n';
20-
exec("state");
21-
*this << getPrompt();
19+
if (retroShell.inDebugShell()) {
20+
21+
*this << '\n';
22+
exec("state");
23+
*this << getPrompt();
24+
}
2225
}
2326

2427
string

Core/Misc/RetroShell/NavigatorConsole.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ NavigatorConsole::autoComplete(Tokens &argv)
8989
if (remaining.size() != 1 || !cmd->autoComplete(argv.back())) {
9090

9191
// If that didn't work, try to auto-complete with a file name
92-
auto prefix = autoCompleteFilename(argv.back());
92+
try {
93+
auto prefix = autoCompleteFilename(argv.back());
94+
if (prefix.size() > argv.back().size()) argv.back() = prefix;
9395

94-
if (prefix.size() > argv.back().size()) argv.back() = prefix;
96+
} catch (...) { }
9597
}
9698
}
9799
}
@@ -271,8 +273,11 @@ NavigatorConsole::matchPath(const string &path, Tokens &notFound)
271273
auto *p = &fs.pwd();
272274
while (!tokens.empty()) {
273275

274-
if (p = fs.seekPtr(p, FSName(tokens.front())); !p) { break; }
276+
auto *next = fs.seekPtr(p, FSName(tokens.front()));
277+
if (!next) break;
278+
275279
tokens.erase(tokens.begin());
280+
p = next;
276281
}
277282
notFound = tokens;
278283

@@ -915,6 +920,7 @@ NavigatorConsole::initCommands(RSCommand &root)
915920
}
916921
});
917922

923+
/* TODO: IMPLEMENT IT! (DO NOT DELETE)
918924
root.add({
919925
920926
.tokens = { "block", "import" },
@@ -942,6 +948,7 @@ NavigatorConsole::initCommands(RSCommand &root)
942948
os << "Not implemented, yet!" << '\n';
943949
}
944950
});
951+
*/
945952

946953
RSCommand::currentGroup = "Modify";
947954

Core/Misc/RetroShell/RetroShell.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@ RetroShell::enterConsole(isize nr)
6767
// Enter Leave tracking mode
6868
nr == 1 ? emulator.trackOn(1) : emulator.trackOff(1);
6969

70-
// Print the welcome message if entered the first time
71-
if (current->isEmpty()) { current->exec("welcome"); *this << current->getPrompt(); }
70+
if (current->isEmpty()) {
71+
72+
// Print the welcome message if entered the first time
73+
current->exec("welcome"); *this << current->getPrompt();
74+
75+
} else {
76+
77+
// Otherwise, print the summary message
78+
current->summary();
79+
}
7280

73-
// Print the summary message
74-
current->summary();
75-
7681
// Update prompt
7782
*this << '\r' << current->getPrompt();
7883

@@ -320,20 +325,6 @@ RetroShell::press(RSKey key, bool shift)
320325

321326
switch(key) {
322327

323-
/*
324-
case RSKey::UP:
325-
case RSKey::PAGE_UP:
326-
327-
asyncExec("..");
328-
return;
329-
330-
case RSKey::DOWN:
331-
case RSKey::PAGE_DOWN:
332-
333-
asyncExec(".");
334-
return;
335-
*/
336-
337328
case RSKey::TAB:
338329

339330
// asyncExec(".");

0 commit comments

Comments
 (0)