Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
20ad1a03
Commit
20ad1a03
authored
Feb 24, 2011
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dokan: more tweaks for MSOffice compatability
parent
1e313d27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
fs/expose/dokan/__init__.py
+20
-22
No files found.
fs/expose/dokan/__init__.py
View file @
20ad1a03
...
@@ -64,7 +64,7 @@ import errno
...
@@ -64,7 +64,7 @@ import errno
import
time
import
time
import
stat
as
statinfo
import
stat
as
statinfo
import
subprocess
import
subprocess
import
p
ickle
import
cP
ickle
import
datetime
import
datetime
import
ctypes
import
ctypes
import
Queue
import
Queue
...
@@ -156,11 +156,6 @@ DATETIME_STARTUP = datetime.datetime.utcnow()
...
@@ -156,11 +156,6 @@ DATETIME_STARTUP = datetime.datetime.utcnow()
FILETIME_UNIX_EPOCH
=
116444736000000000
FILETIME_UNIX_EPOCH
=
116444736000000000
def
_debug
(
*
args
):
#print >>sys.stderr, args; sys.stderr.flush()
#logger.debug(map(str,args))
pass
def
handle_fs_errors
(
func
):
def
handle_fs_errors
(
func
):
"""Method decorator to report FS errors in the appropriate way.
"""Method decorator to report FS errors in the appropriate way.
...
@@ -174,24 +169,18 @@ def handle_fs_errors(func):
...
@@ -174,24 +169,18 @@ def handle_fs_errors(func):
func
=
convert_fs_errors
(
func
)
func
=
convert_fs_errors
(
func
)
@wraps
(
func
)
@wraps
(
func
)
def
wrapper
(
*
args
,
**
kwds
):
def
wrapper
(
*
args
,
**
kwds
):
_debug
(
"CALL"
,
name
,
args
[
1
:
-
1
])
try
:
try
:
res
=
func
(
*
args
,
**
kwds
)
res
=
func
(
*
args
,
**
kwds
)
except
OSError
,
e
:
except
OSError
,
e
:
_debug
(
"ERR"
,
name
,
e
)
if
e
.
errno
:
if
e
.
errno
:
res
=
-
1
*
_errno2syserrcode
(
e
.
errno
)
res
=
-
1
*
_errno2syserrcode
(
e
.
errno
)
else
:
else
:
res
=
-
1
res
=
-
1
except
Exception
,
e
:
except
Exception
,
e
:
_debug
(
"ERR"
,
name
,
e
)
raise
raise
else
:
else
:
_debug
(
"OK"
,
name
)
if
res
is
None
:
if
res
is
None
:
res
=
0
res
=
0
if
res
!=
0
:
_debug
(
"RES"
,
name
,
res
)
return
res
return
res
return
wrapper
return
wrapper
...
@@ -366,11 +355,11 @@ class FSOperations(object):
...
@@ -366,11 +355,11 @@ class FSOperations(object):
except
KeyError
:
except
KeyError
:
return
0
return
0
for
(
lh
,
lstart
,
lend
)
in
locks
:
for
(
lh
,
lstart
,
lend
)
in
locks
:
if
info
is
not
None
and
info
.
contents
.
Context
==
l
f
:
if
info
is
not
None
and
info
.
contents
.
Context
==
l
h
:
continue
continue
if
lstart
>=
offset
+
length
:
if
lstart
>=
offset
+
length
:
continue
continue
if
lend
<
offset
:
if
lend
<
=
offset
:
continue
continue
return
-
ERROR_LOCKED
return
-
ERROR_LOCKED
return
0
return
0
...
@@ -549,7 +538,7 @@ class FSOperations(object):
...
@@ -549,7 +538,7 @@ class FSOperations(object):
@timeout_protect
@timeout_protect
@handle_fs_errors
@handle_fs_errors
def
FlushFileBuffers
(
self
,
path
,
offset
,
info
):
def
FlushFileBuffers
(
self
,
path
,
info
):
path
=
normpath
(
path
)
path
=
normpath
(
path
)
(
file
,
_
,
lock
)
=
self
.
_get_file
(
info
.
contents
.
Context
)
(
file
,
_
,
lock
)
=
self
.
_get_file
(
info
.
contents
.
Context
)
lock
.
acquire
()
lock
.
acquire
()
...
@@ -616,7 +605,11 @@ class FSOperations(object):
...
@@ -616,7 +605,11 @@ class FSOperations(object):
atime
=
_filetime2datetime
(
atime
.
contents
)
atime
=
_filetime2datetime
(
atime
.
contents
)
if
mtime
is
not
None
:
if
mtime
is
not
None
:
mtime
=
_filetime2datetime
(
mtime
.
contents
)
mtime
=
_filetime2datetime
(
mtime
.
contents
)
self
.
fs
.
settimes
(
path
,
atime
,
mtime
)
# some programs demand this succeed; fake it
try
:
self
.
fs
.
settimes
(
path
,
atime
,
mtime
)
except
UnsupportedError
:
pass
@timeout_protect
@timeout_protect
@handle_fs_errors
@handle_fs_errors
...
@@ -700,13 +693,15 @@ class FSOperations(object):
...
@@ -700,13 +693,15 @@ class FSOperations(object):
sz
=
(
len
(
nm
.
value
)
+
1
)
*
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
sz
=
(
len
(
nm
.
value
)
+
1
)
*
ctypes
.
sizeof
(
ctypes
.
c_wchar
)
ctypes
.
memmove
(
fnmBuf
,
nm
,
sz
)
ctypes
.
memmove
(
fnmBuf
,
nm
,
sz
)
@timeout_protect
@handle_fs_errors
@handle_fs_errors
def
SetAllocationSize
(
self
,
path
,
length
,
info
):
def
SetAllocationSize
(
self
,
path
,
length
,
info
):
# I think this is supposed to reserve space for the file
# I think this is supposed to reserve space for the file
# but *not* actually move the end-of-file marker.
# but *not* actually move the end-of-file marker.
# No way to do that in pyfs.
# No way to do that in pyfs.
pass
return
0
@timeout_protect
@handle_fs_errors
@handle_fs_errors
def
LockFile
(
self
,
path
,
offset
,
length
,
info
):
def
LockFile
(
self
,
path
,
offset
,
length
,
info
):
end
=
offset
+
length
end
=
offset
+
length
...
@@ -722,8 +717,9 @@ class FSOperations(object):
...
@@ -722,8 +717,9 @@ class FSOperations(object):
locks
.
append
((
info
.
contents
.
Context
,
offset
,
end
))
locks
.
append
((
info
.
contents
.
Context
,
offset
,
end
))
return
0
return
0
@timeout_protect
@handle_fs_errors
@handle_fs_errors
def
UnlockFile
(
self
,
path
,
byteO
ffset
,
length
,
info
):
def
UnlockFile
(
self
,
path
,
o
ffset
,
length
,
info
):
end
=
offset
+
length
end
=
offset
+
length
with
self
.
_files_lock
:
with
self
.
_files_lock
:
try
:
try
:
...
@@ -968,9 +964,11 @@ class MountProcess(subprocess.Popen):
...
@@ -968,9 +964,11 @@ class MountProcess(subprocess.Popen):
raise
OSError
(
"the dokan library is not available"
)
raise
OSError
(
"the dokan library is not available"
)
self
.
drive
=
_normalise_drive_string
(
drive
)
self
.
drive
=
_normalise_drive_string
(
drive
)
self
.
path
=
self
.
drive
+
":
\\
"
self
.
path
=
self
.
drive
+
":
\\
"
cmd
=
'from fs.expose.dokan import MountProcess; '
cmd
=
"import cPickle; "
cmd
=
cmd
+
'MountProcess._do_mount(
%
s)'
cmd
=
cmd
+
"data = cPickle.loads(
%
s); "
cmd
=
cmd
%
(
repr
(
pickle
.
dumps
((
fs
,
drive
,
dokan_opts
,
nowait
),
-
1
)),)
cmd
=
cmd
+
"from fs.expose.dokan import MountProcess; "
cmd
=
cmd
+
"MountProcess._do_mount(data)"
cmd
=
cmd
%
(
repr
(
cPickle
.
dumps
((
fs
,
drive
,
dokan_opts
,
nowait
),
-
1
)),)
cmd
=
[
sys
.
executable
,
"-c"
,
cmd
]
cmd
=
[
sys
.
executable
,
"-c"
,
cmd
]
super
(
MountProcess
,
self
)
.
__init__
(
cmd
,
**
kwds
)
super
(
MountProcess
,
self
)
.
__init__
(
cmd
,
**
kwds
)
...
@@ -993,7 +991,7 @@ class MountProcess(subprocess.Popen):
...
@@ -993,7 +991,7 @@ class MountProcess(subprocess.Popen):
@staticmethod
@staticmethod
def
_do_mount
(
data
):
def
_do_mount
(
data
):
"""Perform the specified mount."""
"""Perform the specified mount."""
(
fs
,
drive
,
opts
,
nowait
)
=
pickle
.
loads
(
data
)
(
fs
,
drive
,
opts
,
nowait
)
=
data
opts
[
"foreground"
]
=
True
opts
[
"foreground"
]
=
True
def
unmount_callback
():
def
unmount_callback
():
fs
.
close
()
fs
.
close
()
...
...
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