Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tree-view-sample/src/ftpExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class FtpModel {

client.end();

return c(this.sort(list.map(entry => ({ resource: vscode.Uri.parse(`ftp://${this.host}///${entry.name}`), isDirectory: entry.type === 'd' }))));
return c(this.sort(list.map(entry => ({ resource: vscode.Uri.parse(`ftp://${this.host}//${entry.name}`), isDirectory: entry.type === 'd' }))));
});
});
});
Expand All @@ -58,7 +58,12 @@ export class FtpModel {

client.end();

return c(this.sort(list.map(entry => ({ resource: vscode.Uri.parse(`${node.resource.fsPath}/${entry.name}`), isDirectory: entry.type === 'd' }))));
return c(this.sort(list.map(entry => {
const path = node.resource.path.endsWith('/')
? `${node.resource.path}${entry.name}`
: `${node.resource.path}/${entry.name}`;
return { resource: node.resource.with({ path }), isDirectory: entry.type === 'd' };
})));
});
});
});
Expand All @@ -81,7 +86,7 @@ export class FtpModel {
public getContent(resource: vscode.Uri): Thenable<string> {
return this.connect().then(client => {
return new Promise((c, e) => {
client.get(resource.path.substr(2), (err, stream) => {
client.get(resource.path.substr(1), (err, stream) => {
if (err) {
return e(err);
}
Expand Down Expand Up @@ -148,7 +153,7 @@ export class FtpExplorer {

constructor(context: vscode.ExtensionContext) {
/* Please note that login information is hardcoded only for this example purpose and recommended not to do it in general. */
const ftpModel = new FtpModel('mirror.switch.ch', 'anonymous', 'anonymous@anonymous.de');
const ftpModel = new FtpModel('test.rebex.net', 'anonymous', 'anonymous@anonymous.de');
const treeDataProvider = new FtpTreeDataProvider(ftpModel);
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('ftp', treeDataProvider));

Expand Down