Set the custom icon for the specified file or directory.
(filePath, icnsPath)
| 1690 | |
| 1691 | |
| 1692 | def setIcon(filePath, icnsPath): |
| 1693 | """ |
| 1694 | Set the custom icon for the specified file or directory. |
| 1695 | """ |
| 1696 | |
| 1697 | dirPath = os.path.normpath(os.path.dirname(__file__)) |
| 1698 | toolPath = os.path.join(dirPath, "seticon.app/Contents/MacOS/seticon") |
| 1699 | if not os.path.exists(toolPath) or os.stat(toolPath).st_mtime < os.stat(dirPath + '/seticon.m').st_mtime: |
| 1700 | # NOTE: The tool is created inside an .app bundle, otherwise it won't work due |
| 1701 | # to connections to the window server. |
| 1702 | appPath = os.path.join(dirPath, "seticon.app/Contents/MacOS") |
| 1703 | if not os.path.exists(appPath): |
| 1704 | os.makedirs(appPath) |
| 1705 | runCommand("cc -o %s %s/seticon.m -framework Cocoa"%( |
| 1706 | shellQuote(toolPath), shellQuote(dirPath))) |
| 1707 | |
| 1708 | runCommand("%s %s %s"%(shellQuote(os.path.abspath(toolPath)), shellQuote(icnsPath), |
| 1709 | shellQuote(filePath))) |
| 1710 | |
| 1711 | def main(): |
| 1712 | # First parse options and check if we can perform our work |
no test coverage detected
searching dependent graphs…