0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import sys, zipfile, os, os.path
|
|
18 |
|
|
19 |
def unzip_file_into_dir(file, dir):
|
|
20 |
if (os.path.exists(file) is not True):
|
|
21 |
return
|
|
22 |
|
|
23 |
if (os.path.exists(dir) is not True):
|
|
24 |
os.mkdir(dir, 0777)
|
|
25 |
zfobj = zipfile.ZipFile(file)
|
|
26 |
for name in zfobj.namelist():
|
|
27 |
filePath = dir + name
|
|
28 |
if name.endswith('/'):
|
5
|
29 |
if not os.path.exists(filePath):
|
|
30 |
createEmtyResource(filePath)
|
|
31 |
#os.mkdir(filePath)
|
0
|
32 |
else:
|
5
|
33 |
if not os.path.exists(filePath):
|
|
34 |
createEmtyResource(filePath)
|
|
35 |
outfile = open(dir+ name, 'wb')
|
|
36 |
outfile.write(zfobj.read(name))
|
|
37 |
outfile.close()
|
0
|
38 |
|
|
39 |
def createEmtyResource(path):
|
|
40 |
splitdrive = os.path.splitdrive(path)
|
|
41 |
splitPath = os.path.split(splitdrive[1])
|
|
42 |
|
|
43 |
pathS = os.path.split(splitPath[1])
|
|
44 |
splited = path.split("/")
|
|
45 |
tempPath = ""
|
|
46 |
for i in range(0,len(splited)-1):
|
|
47 |
tempPath = tempPath+splited[i]
|
|
48 |
if (os.path.exists(tempPath) is not True):
|
|
49 |
os.mkdir(tempPath)
|
|
50 |
tempPath = tempPath+os.path.sep
|
|
51 |
if (os.path.exists(path) is not True):
|
|
52 |
file(path,'wt')
|