1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/usr/bin/python
# -*- coding: UTF-8 -*-
###########################################################################
# wineread.py - description #
# ------------------------------ #
# begin : Fri Mar 26 2004 #
# copyright : (C) 2006 by Yuriy Kozlov #
# email : [email protected] #
# #
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
import os
import wineread
""" Reads a default set of drives from /etc/fstab """
fstabpath = "/etc/fstab"
# Listed in winecfg
ignored_fs_types = set(["devpts",
"tmpfs",
"proc",
"sysfs",
"swap",
"usbdevfs",
"rpc_pipefs",
"binfmt_misc"])
# Listed in winecfg
ignored_mnt_pts = set(["/boot"])
cd_fs_types = set(["cdfs","udf","iso9660"])
# An incomplete listing, I don't know how winecfg does this.
# RAMFS is included here because I don't know what the correct type for it is in wine.
hd_fs_types = set(["ext4","ext3","ext2","ext","fat","fat32","fat16","ntfs","reiserfs","reiser4",
"jfs","xfs","ramfs","vfat","ufs","hfs","hfsplus"])
# Listed in winecfg
net_fs_types = set(["nfs","nfs4","smbfs","cifs","coda"])
def autodetect(drives=None):
""" Returns a set of drives found by scanning /etc/fstab, and an error code """
if not drives:
drives = wineread.GetEmptyDrives()
mappings = set()
if not drives[2][2]:
drives[2][2] = "../drive_c"
drives[2][3] = "hd"
for drive in drives:
mapping = drive[2]
if mapping:
mappings.add(mapping)
driveid = 3
fstab=open(fstabpath,'r')
for driveline in fstab:
if driveline[0] == '#' or len(driveline.strip()) == 0: # Comment or empty line
continue
else:
driveprops = driveline.split()
fs = driveprops[0]
mnt = driveprops[1]
fstypes = set(driveprops[2].split(','))
ignore = False
for fstype in fstypes:
if fstype in ignored_fs_types:
ignore = True
break
if mnt in ignored_mnt_pts or mnt in mappings:
ignore = True
if not ignore:
while drives[driveid][2]: # Drive is in use, don't overwrite.
driveid += 1
if driveid > 25:
return (1,drives)
drives[driveid][2] = mnt
if "/dev/fd" in fs or "floppy" in mnt:
drives[driveid][3] = "floppy"
elif fstype in cd_fs_types or "/dev/cdrom" in fs or "cdrom" in mnt:
drives[driveid][3] = "cdrom"
elif fstype in hd_fs_types:
drives[driveid][3] = "hd"
elif fstype in net_fs_types:
drives[driveid][3] = "network"
else:
drives[driveid][3] = "auto"
driveid += 1
fstab.close()
return (0,drives)
def autodetectshelllinks(shelllinks = None):
""" Returns a default set of windows shell folder mappings """
if not shelllinks:
shelllinks = wineread.GetEmptyShellLinks()
for link in shelllinks:
if link[2]:
continue
else:
link[3] = "shellfolder"
#link[4] = wineread.winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER'] + "/" + link[1]
link[4] = wineread.defaultwinfolderspath + "\\" + link[1]
link[5] = wineread.defaultwinfolderspath + "\\" + link[1]
link[2] = os.environ['HOME']
if link[1] == "Desktop":
link[2] = os.environ['HOME'] + "/Desktop"
return shelllinks
|