File: CopyDirectory.py

package info (click to toggle)
shasta 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,636 kB
  • sloc: cpp: 82,262; python: 2,348; makefile: 222; sh: 143
file content (40 lines) | stat: -rwxr-xr-x 1,086 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python3

import glob
import shasta
import sys

helpMessage = """
This can be used to copy all files in a directory
to the huge page filesystem.
The regular cp command does not work (but it works to copy
the other way around, from the huge page filesystem).

All files in the input directory must have size equal to a multiple of the page
size of the huge page filesystem. This will always be the case
if the files were oroginally copied from a huge page filesystem
with the same page size.

Invoke with two arguments:
- The path for the input directory.
- The path for the output directory.
Both directories must exist. 
The second one will be a symbolic link to the huge page filesystem.

"""

if not len(sys.argv) == 3:
    print(helpMessage)
    exit(1)
    
inputName = sys.argv[1]
outputName = sys.argv[2]

inputFileNames = glob.glob(inputName + '/*')

for inputFileName in inputFileNames:
    lastSlashPosition = inputFileName.rfind('/')
    outputFileName = outputName + '/' + inputFileName[lastSlashPosition+1:]
    shasta.mappedCopy(inputFileName, outputFileName)