Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
9c830a11
Commit
9c830a11
authored
Apr 20, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented mkdir and rmdir
parent
df91b923
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
fileManager.js
src/app/files/fileManager.js
+9
-4
fileProvider.js
src/app/files/fileProvider.js
+21
-13
No files found.
src/app/files/fileManager.js
View file @
9c830a11
...
@@ -133,9 +133,9 @@ class FileManager extends Plugin {
...
@@ -133,9 +133,9 @@ class FileManager extends Plugin {
* @returns {boolean} true if path is a file.
* @returns {boolean} true if path is a file.
*/
*/
isFile
(
path
)
{
isFile
(
path
)
{
const
extension
=
path
.
split
(
'/'
).
pop
(
)
const
provider
=
this
.
fileProviderOf
(
path
)
return
extension
&&
extension
.
indexOf
(
'.'
)
>
-
1
return
provider
.
isFile
(
path
)
}
}
/**
/**
...
@@ -218,7 +218,9 @@ class FileManager extends Plugin {
...
@@ -218,7 +218,9 @@ class FileManager extends Plugin {
if
(
this
.
exists
(
path
))
{
if
(
this
.
exists
(
path
))
{
this
.
_handleError
({
code
:
'EEXIST'
,
message
:
`Cannot create directory
${
path
}
`
})
this
.
_handleError
({
code
:
'EEXIST'
,
message
:
`Cannot create directory
${
path
}
`
})
}
}
// To implement
const
provider
=
this
.
fileProviderOf
(
path
)
provider
.
createDir
(
path
)
}
}
/**
/**
...
@@ -249,7 +251,10 @@ class FileManager extends Plugin {
...
@@ -249,7 +251,10 @@ class FileManager extends Plugin {
rmdir
(
path
)
{
rmdir
(
path
)
{
this
.
_handleExists
(
path
,
`Cannot remove directory
${
path
}
`
)
this
.
_handleExists
(
path
,
`Cannot remove directory
${
path
}
`
)
this
.
_handleIsDir
(
path
,
`Cannot remove directory
${
path
}
`
)
this
.
_handleIsDir
(
path
,
`Cannot remove directory
${
path
}
`
)
// To implement
const
provider
=
this
.
fileProviderOf
(
path
)
return
provider
.
remove
(
path
)
}
}
init
()
{
init
()
{
...
...
src/app/files/fileProvider.js
View file @
9c830a11
...
@@ -79,7 +79,6 @@ class FileProvider {
...
@@ -79,7 +79,6 @@ class FileProvider {
}
}
get
(
path
,
cb
)
{
get
(
path
,
cb
)
{
console
.
log
(
'window.remixFileSystem: '
,
window
.
remixFileSystem
)
cb
=
cb
||
function
()
{}
cb
=
cb
||
function
()
{}
path
=
this
.
getPathFromUrl
(
path
)
||
path
// ensure we actually use the normalized path from here
path
=
this
.
getPathFromUrl
(
path
)
||
path
// ensure we actually use the normalized path from here
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
...
@@ -95,19 +94,8 @@ class FileProvider {
...
@@ -95,19 +94,8 @@ class FileProvider {
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
var
exists
=
window
.
remixFileSystem
.
existsSync
(
unprefixedpath
)
if
(
exists
&&
window
.
remixFileSystem
.
readFileSync
(
unprefixedpath
,
'utf8'
)
===
content
)
return
true
if
(
exists
&&
window
.
remixFileSystem
.
readFileSync
(
unprefixedpath
,
'utf8'
)
===
content
)
return
true
if
(
!
exists
&&
unprefixedpath
.
indexOf
(
'/'
)
!==
-
1
)
{
if
(
!
exists
&&
unprefixedpath
.
indexOf
(
'/'
)
!==
-
1
)
{
const
paths
=
unprefixedpath
.
split
(
'/'
)
this
.
createDir
(
path
)
paths
.
pop
()
// last element should the filename
if
(
paths
.
length
&&
paths
[
0
]
===
''
)
paths
.
shift
()
let
currentCheck
=
''
paths
.
forEach
((
value
)
=>
{
currentCheck
=
currentCheck
+
'/'
+
value
if
(
!
window
.
remixFileSystem
.
existsSync
(
currentCheck
))
{
window
.
remixFileSystem
.
mkdirSync
(
currentCheck
)
this
.
event
.
trigger
(
'folderAdded'
,
[
this
.
_normalizePath
(
currentCheck
)])
}
})
}
}
try
{
try
{
window
.
remixFileSystem
.
writeFileSync
(
unprefixedpath
,
content
)
window
.
remixFileSystem
.
writeFileSync
(
unprefixedpath
,
content
)
...
@@ -124,6 +112,22 @@ class FileProvider {
...
@@ -124,6 +112,22 @@ class FileProvider {
return
true
return
true
}
}
createDir
(
path
,
cb
)
{
var
unprefixedpath
=
this
.
removePrefix
(
path
)
const
paths
=
unprefixedpath
.
split
(
'/'
)
paths
.
pop
()
// last element should the filename
if
(
paths
.
length
&&
paths
[
0
]
===
''
)
paths
.
shift
()
let
currentCheck
=
''
paths
.
forEach
((
value
)
=>
{
currentCheck
=
currentCheck
+
'/'
+
value
if
(
!
window
.
remixFileSystem
.
existsSync
(
currentCheck
))
{
window
.
remixFileSystem
.
mkdirSync
(
currentCheck
)
this
.
event
.
trigger
(
'folderAdded'
,
[
this
.
_normalizePath
(
currentCheck
)])
}
})
if
(
cb
)
cb
()
}
// this will not add a folder as readonly but keep the original url to be able to restore it later
// this will not add a folder as readonly but keep the original url to be able to restore it later
addExternal
(
path
,
content
,
url
)
{
addExternal
(
path
,
content
,
url
)
{
if
(
url
)
this
.
addNormalizedName
(
path
,
url
)
if
(
url
)
this
.
addNormalizedName
(
path
,
url
)
...
@@ -138,6 +142,10 @@ class FileProvider {
...
@@ -138,6 +142,10 @@ class FileProvider {
return
window
.
remixFileSystem
.
statSync
(
path
).
isDirectory
()
return
window
.
remixFileSystem
.
statSync
(
path
).
isDirectory
()
}
}
isFile
(
path
)
{
return
window
.
remixFileSystem
.
statSync
(
path
).
isFile
()
}
/**
/**
* Removes the folder recursively
* Removes the folder recursively
* @param {*} path is the folder to be removed
* @param {*} path is the folder to be removed
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment