提交 aa0439df 编写于 作者: J Johannes Rieken

have unlink and rmdir

上级 94deeec3
...@@ -167,12 +167,13 @@ export interface IStat { ...@@ -167,12 +167,13 @@ export interface IStat {
export interface IFileSystemProvider { export interface IFileSystemProvider {
onDidChange?: Event<FileChangesEvent>; onDidChange?: Event<FileChangesEvent>;
stat(resource: URI): TPromise<IStat>; stat(resource: URI): TPromise<IStat>;
readdir(resource: URI): TPromise<URI[]>;
mkdir(resource: URI): TPromise<void>;
read(resource: URI, progress: IProgress<Uint8Array>): TPromise<void>; read(resource: URI, progress: IProgress<Uint8Array>): TPromise<void>;
write(resource: URI, content: Uint8Array): TPromise<void>; write(resource: URI, content: Uint8Array): TPromise<void>;
unlink(resource: URI): TPromise<void>;
rename(resource: URI, target: URI): TPromise<void>; rename(resource: URI, target: URI): TPromise<void>;
del(resource: URI): TPromise<void>; mkdir(resource: URI): TPromise<void>;
readdir(resource: URI): TPromise<URI[]>;
rmdir(resource: URI): TPromise<void>;
} }
......
...@@ -93,23 +93,18 @@ export class FtpFileSystemProvider implements IFileSystemProvider { ...@@ -93,23 +93,18 @@ export class FtpFileSystemProvider implements IFileSystemProvider {
return ninvoke(this._connection, this._connection.put, content, resource.path); return ninvoke(this._connection, this._connection.put, content, resource.path);
} }
del(resource: URI): TPromise<void> { rmdir(resource: URI): TPromise<void> {
return ninvoke(this._connection, this._connection.raw, 'RMD', [resource.path]);
return ninvoke<JSFtp.Entry[]>(this._connection, this._connection.ls, resource.path).then(entries => {
if (entries.length === 1) {
// file;
return ninvoke(this._connection, this._connection.raw, 'DELE', [resource.path]);
} else {
// dir
return ninvoke(this._connection, this._connection.raw, 'RMD', [resource.path]);
}
});
} }
mkdir(resource: URI): TPromise<void> { mkdir(resource: URI): TPromise<void> {
return ninvoke(this._connection, this._connection.raw, 'MKD', [resource.path]); return ninvoke(this._connection, this._connection.raw, 'MKD', [resource.path]);
} }
unlink(resource: URI): TPromise<void> {
return ninvoke(this._connection, this._connection.raw, 'DELE', [resource.path]);
}
rename(resource: URI, target: URI): TPromise<void> { rename(resource: URI, target: URI): TPromise<void> {
return ninvoke(this._connection, this._connection.raw, 'RNFR', [resource.path]).then(() => { return ninvoke(this._connection, this._connection.raw, 'RNFR', [resource.path]).then(() => {
return ninvoke(this._connection, this._connection.raw, 'RNTO', [target.path]); return ninvoke(this._connection, this._connection.raw, 'RNTO', [target.path]);
......
...@@ -258,7 +258,8 @@ export class RemoteFileService extends FileService { ...@@ -258,7 +258,8 @@ export class RemoteFileService extends FileService {
async del(resource: URI, useTrash?: boolean): TPromise<void> { async del(resource: URI, useTrash?: boolean): TPromise<void> {
const provider = this._provider.get(resource.scheme); const provider = this._provider.get(resource.scheme);
if (provider) { if (provider) {
await provider.del(resource); const stat = await provider.stat(resource);
await stat.type === FileType.Dir ? provider.rmdir(resource) : provider.unlink(resource);
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE)); this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
} else { } else {
return super.del(resource, useTrash); return super.del(resource, useTrash);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册