Home | History | Annotate | Download | only in build
      1 #!/usr/bin/env python
      2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 # Extracts a single file from a CAB archive.
      7 
      8 import os
      9 import subprocess
     10 import sys
     11 
     12 if len(sys.argv) != 4:
     13   print 'Usage: extract_from_cab.py cab_path archived_file output_dir'
     14   sys.exit(1)
     15 
     16 [cab_path, archived_file, output_dir] = sys.argv[1:]
     17 
     18 # Invoke the Windows expand utility to extract the file.
     19 level = subprocess.call(['expand', cab_path, '-F:' + archived_file, output_dir])
     20 if level != 0:
     21   sys.exit(level)
     22 
     23 # The expand utility preserves the modification date and time of the archived
     24 # file. Touch the extracted file. This helps build systems that compare the
     25 # modification times of input and output files to determine whether to do an
     26 # action.
     27 os.utime(os.path.join(output_dir, archived_file), None)
     28