Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3500eb87
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3500eb87
编写于
4月 19, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
back to FileError, #47475
上级
57a92cb3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
73 addition
and
51 deletion
+73
-51
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+0
-18
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+10
-24
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
...vs/workbench/api/electron-browser/mainThreadFileSystem.ts
+2
-2
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+26
-0
src/vs/workbench/services/files/electron-browser/remoteFileService.ts
...ench/services/files/electron-browser/remoteFileService.ts
+34
-6
未找到文件。
src/vs/platform/files/common/files.ts
浏览文件 @
3500eb87
...
...
@@ -156,24 +156,6 @@ export enum FileType2 {
SymbolicLink
=
4
,
}
export
class
FileError
extends
Error
{
static
readonly
EntryExists
=
new
FileError
(
'
EEXIST
'
);
static
readonly
EntryNotFound
=
new
FileError
(
'
ENOENT
'
);
static
readonly
EntryNotADirectory
=
new
FileError
(
'
ENOTDIR
'
);
static
readonly
EntryIsADirectory
=
new
FileError
(
'
EISDIR
'
);
constructor
(
readonly
code
:
string
,
message
?:
string
)
{
super
(
message
||
code
);
}
is
(
err
:
any
):
err
is
FileError
{
if
(
!
err
||
typeof
err
!==
'
object
'
)
{
return
false
;
}
return
err
.
code
===
this
.
code
;
}
}
export
enum
FileOpenFlags
{
Read
=
0b0001
,
Write
=
0b0010
,
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
3500eb87
...
...
@@ -84,32 +84,18 @@ declare module 'vscode' {
// create(resource: Uri): Thenable<FileStat>;
}
// export class FileError extends Error {
// /**
// * Entry already exists, e.g. when creating a file or folder.
// */
// static readonly EntryExists: FileError;
// /**
// * Entry does not exist.
// */
// static readonly EntryNotFound: FileError;
// /**
// * Entry is not a directory.
// */
// static readonly EntryNotADirectory: FileError;
// /**
// * Entry is a directory.
// */
// static readonly EntryIsADirectory: FileError;
/**
*
*/
export
class
FileError
extends
Error
{
// readonly code: string;
static
EntryExists
(
message
?:
string
):
FileError
;
static
EntryNotFound
(
message
?:
string
):
FileError
;
static
EntryNotADirectory
(
message
?:
string
):
FileError
;
static
EntryIsADirectory
(
message
?:
string
):
FileError
;
// constructor(code: string,
message?: string);
//
}
constructor
(
message
?:
string
);
}
export
enum
FileChangeType2
{
Changed
=
1
,
...
...
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
浏览文件 @
3500eb87
...
...
@@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
FileOpenFlags
,
IFileChange
,
IFileService
,
IStat
,
IWatchOptions
,
FileError
,
FileSystemProviderCapabilities
,
IFileSystemProvider
}
from
'
vs/platform/files/common/files
'
;
import
{
FileOpenFlags
,
FileSystemProviderCapabilities
,
IFileChange
,
IFileService
,
IFileSystemProvider
,
IStat
,
IWatchOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
ExtHostContext
,
ExtHostFileSystemShape
,
IExtHostContext
,
IFileChangeDto
,
MainContext
,
MainThreadFileSystemShape
}
from
'
../node/extHost.protocol
'
;
...
...
@@ -88,7 +88,7 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
// --- forwarding calls
stat
(
resource
:
URI
):
TPromise
<
IStat
,
FileError
>
{
stat
(
resource
:
URI
):
TPromise
<
IStat
>
{
return
this
.
_proxy
.
$stat
(
this
.
_handle
,
resource
).
then
(
undefined
,
err
=>
{
throw
err
;
});
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
3500eb87
...
...
@@ -713,7 +713,7 @@ export function createApiFactory(
FileChangeType2
:
extHostTypes
.
FileChangeType2
,
FileType2
:
extHostTypes
.
FileType2
,
FileOpenFlags
:
files
.
FileOpenFlags
,
FileError
:
fil
es
.
FileError
,
FileError
:
extHostTyp
es
.
FileError
,
FoldingRange
:
extHostTypes
.
FoldingRange
,
FoldingRangeKind
:
extHostTypes
.
FoldingRangeKind
};
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
3500eb87
...
...
@@ -1838,6 +1838,32 @@ export enum FileType2 {
SymbolicLink
=
4
,
}
export
class
FileError
extends
Error
{
static
EntryExists
(
message
?:
string
):
FileError
{
return
new
FileError
(
message
,
'
EntryExists
'
,
FileError
.
EntryExists
);
}
static
EntryNotFound
(
message
?:
string
):
FileError
{
return
new
FileError
(
message
,
'
EntryNotFound
'
,
FileError
.
EntryNotFound
);
}
static
EntryNotADirectory
(
message
?:
string
):
FileError
{
return
new
FileError
(
message
,
'
EntryNotADirectory
'
,
FileError
.
EntryNotADirectory
);
}
static
EntryIsADirectory
(
message
?:
string
):
FileError
{
return
new
FileError
(
message
,
'
EntryIsADirectory
'
,
FileError
.
EntryIsADirectory
);
}
constructor
(
message
?:
string
,
code
?:
string
,
hide
?:
Function
)
{
super
(
message
);
this
.
name
=
code
?
`FileError/
${
code
}
`
:
`FileError`
;
if
(
typeof
Error
.
captureStackTrace
===
'
function
'
&&
typeof
hide
===
'
function
'
)
{
// nice stack traces
Error
.
captureStackTrace
(
this
,
hide
);
}
}
}
//#endregion
//#region folding api
...
...
src/vs/workbench/services/files/electron-browser/remoteFileService.ts
浏览文件 @
3500eb87
...
...
@@ -16,7 +16,7 @@ import { ITextResourceConfigurationService } from 'vs/editor/common/services/res
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
FileChangesEvent
,
File
Error
,
File
OpenFlags
,
FileOperation
,
FileOperationError
,
FileOperationEvent
,
FileOperationResult
,
FileType2
,
IContent
,
ICreateFileOptions
,
IFileStat
,
IFileSystemProvider
,
IFilesConfiguration
,
IResolveContentOptions
,
IResolveFileOptions
,
IResolveFileResult
,
IStat
,
IStreamContent
,
ITextSnapshot
,
IUpdateContentOptions
,
StringSnapshot
,
FileSystemProviderCapabilities
}
from
'
vs/platform/files/common/files
'
;
import
{
FileChangesEvent
,
FileOpenFlags
,
FileOperation
,
FileOperationError
,
FileOperationEvent
,
FileOperationResult
,
FileType2
,
IContent
,
ICreateFileOptions
,
IFileStat
,
IFileSystemProvider
,
IFilesConfiguration
,
IResolveContentOptions
,
IResolveFileOptions
,
IResolveFileResult
,
IStat
,
IStreamContent
,
ITextSnapshot
,
IUpdateContentOptions
,
StringSnapshot
,
FileSystemProviderCapabilities
}
from
'
vs/platform/files/common/files
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
...
...
@@ -200,6 +200,32 @@ export class RemoteFileService extends FileService {
||
this
.
_supportedSchemes
.
indexOf
(
resource
.
scheme
)
>=
0
;
}
private
_tryParseFileOperationResult
(
err
:
any
):
FileOperationResult
{
if
(
!
(
err
instanceof
Error
))
{
return
undefined
;
}
let
match
=
/FileError
\/(
.+
)
$/
.
exec
(
err
.
name
);
if
(
!
match
)
{
return
undefined
;
}
let
res
:
FileOperationResult
;
switch
(
match
[
1
])
{
case
'
EntryNotFound
'
:
res
=
FileOperationResult
.
FILE_NOT_FOUND
;
break
;
case
'
EntryIsADirectory
'
:
res
=
FileOperationResult
.
FILE_IS_DIRECTORY
;
break
;
case
'
EntryExists
'
:
case
'
EntryNotADirectory
'
:
default
:
// todo
res
=
undefined
;
break
;
}
return
res
;
}
// --- stat
private
_withProvider
(
resource
:
URI
):
TPromise
<
IFileSystemProvider
>
{
...
...
@@ -229,7 +255,10 @@ export class RemoteFileService extends FileService {
}
else
{
return
this
.
_doResolveFiles
([{
resource
,
options
}]).
then
(
data
=>
{
if
(
data
.
length
!==
1
||
!
data
[
0
].
success
)
{
throw
new
Error
(
`ENOENT,
${
resource
}
`
);
throw
new
FileOperationError
(
localize
(
'
fileNotFoundError
'
,
"
File not found ({0})
"
,
resource
.
toString
(
true
)),
FileOperationResult
.
FILE_NOT_FOUND
);
}
else
{
return
data
[
0
].
stat
;
}
...
...
@@ -369,10 +398,9 @@ export class RemoteFileService extends FileService {
this
.
_onAfterOperation
.
fire
(
new
FileOperationEvent
(
resource
,
FileOperation
.
CREATE
,
fileStat
));
return
fileStat
;
},
err
=>
{
if
(
FileError
.
EntryExists
.
is
(
err
))
{
return
TPromise
.
wrapError
(
new
FileOperationError
(
err
.
code
,
FileOperationResult
.
FILE_MODIFIED_SINCE
,
options
));
}
throw
err
;
const
message
=
localize
(
'
err.create
'
,
"
Failed to create file {0}
"
,
resource
.
toString
(
false
));
const
result
=
this
.
_tryParseFileOperationResult
(
err
);
throw
new
FileOperationError
(
message
,
result
,
options
);
});
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录