summaryrefslogtreecommitdiffstats
path: root/module/utils/fs.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:22 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:23 +0200
commit16af85004c84d0d6c626b4f8424ce9647669a0c1 (patch)
tree025d479862d376dbc17e934f4ed20031c8cd97d1 /module/utils/fs.py
parentadapted to jshint config (diff)
downloadpyload-16af85004c84d0d6c626b4f8424ce9647669a0c1.tar.xz
moved everything from module to pyload
Diffstat (limited to 'module/utils/fs.py')
-rw-r--r--module/utils/fs.py78
1 files changed, 0 insertions, 78 deletions
diff --git a/module/utils/fs.py b/module/utils/fs.py
deleted file mode 100644
index 92cc605e7..000000000
--- a/module/utils/fs.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import os
-import sys
-from os.path import join
-from . import decode, remove_chars
-
-# File System Encoding functions:
-# Use fs_encode before accessing files on disk, it will encode the string properly
-
-if sys.getfilesystemencoding().startswith('ANSI'):
- def fs_encode(string):
- if type(string) == unicode:
- return string.encode('utf8')
- return string
-
- fs_decode = decode #decode utf8
-
-else:
- fs_encode = fs_decode = lambda x: x # do nothing
-
-# FS utilities
-def chmod(path, mode):
- try:
- return os.chmod(fs_encode(path), mode)
- except :
- pass
-
-def dirname(path):
- return fs_decode(os.path.dirname(fs_encode(path)))
-
-def abspath(path):
- return fs_decode(os.path.abspath(fs_encode(path)))
-
-def chown(path, uid, gid):
- return os.chown(fs_encode(path), uid, gid)
-
-def remove(path):
- return os.remove(fs_encode(path))
-
-def exists(path):
- return os.path.exists(fs_encode(path))
-
-def makedirs(path, mode=0755):
- return os.makedirs(fs_encode(path), mode)
-
-# fs_decode?
-def listdir(path):
- return [fs_decode(x) for x in os.listdir(fs_encode(path))]
-
-def save_filename(name):
- #remove some chars
- if os.name == 'nt':
- return remove_chars(name, '/\\?%*:|"<>,')
- else:
- return remove_chars(name, '/\\"')
-
-def stat(name):
- return os.stat(fs_encode(name))
-
-def save_join(*args):
- """ joins a path, encoding aware """
- return fs_encode(join(*[x if type(x) == unicode else decode(x) for x in args]))
-
-def free_space(folder):
- folder = fs_encode(folder)
-
- if os.name == "nt":
- import ctypes
-
- free_bytes = ctypes.c_ulonglong(0)
- ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
- return free_bytes.value
- else:
- from os import statvfs
-
- s = statvfs(folder)
- return s.f_frsize * s.f_bavail