symlink

Python os.walk + follow symlinks

懵懂的女人 提交于 2019-12-03 01:07:37
How do I get this piece to follow symlinks in python 2.6? def load_recursive(self, path): for subdir, dirs, files in os.walk(path): for file in files: if file.endswith('.xml'): file_path = os.path.join(subdir, file) try: do_stuff(file_path) except: continue Set followlinks to True . This is the fourth argument to the os.walk method, reproduced below: os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) This option was added in Python 2.6. 来源: https://stackoverflow.com/questions/3771696/python-os-walk-follow-symlinks

Moving MySQL InnoDB database to separate drive

一曲冷凌霜 提交于 2019-12-03 00:49:45
In my MySQL installation I have one InnoDB database that I know will grow very large so I have decided to move it to its own disk. I was hoping to do this by moving the files to the other disk and then create a symlink but I run into errors! This is what I have done: 1) In my.cnf I have set [mysqld] innodb_file_per_table (This works, I have one .ibd per .frm in the database folder.) 2)I have checked if symlinks are ok with SHOW VARIABLES LIKE "have_symlink"; (I know that the documentation says: Symlinks are fully supported only for MyISAM tables. For files used by tables for other storage

Windows XP vs Vista: NTFS Junction points

*爱你&永不变心* 提交于 2019-12-02 21:36:43
Problem: I relied heavily on NTFS Junction points in Windows XP, even though they apparently were not an "official" feature of the operating system. Now MSFT has generously made NTFS Junction points an official part of Vista, but apparently they also intentionally broke them. Now my WinXP-created junction points on portable USB drive don't work when I plug that drive into a Vista box. Questions: Does anyone have a script that will force NTFS junctions created on XP to work correctly within BOTH Vista and XP? Is there documentation or a spec that explains what MSFT did to cause this breakage?

How to find files excluding symbolic links?

故事扮演 提交于 2019-12-02 21:01:14
I want to find files in Linux that follow a certain pattern but I am not interested in symbolic links. There doesn't seem to be an option to the find command for that. How shall I do ? Check the man page again ;) It's: find /path/to/files -type f type f searches for regular files only - excluding symbolic links. Vittorio Milazzo ! -type l For example, if you want to search all regular files in /usr/bin, excluding symlink: find /usr/bin/ \! -type l Do you want it to follow symlinks but not return them (if they match your pattern)? find -H ? man find ... -H Cause the file information and file

Resolve symbolic links when copying bundle resources in Xcode

只愿长相守 提交于 2019-12-02 19:23:31
I have a project in Xcode and some resources for the project. The resources contain several symbolic links. When Xcode builds the project, it copies the resources, but does not resolve the symbolic links. Is there a way to tell Xcode to resolve the links? (Ie. have the link targets copied instead of the links themselves.) Update: Thanks, mouviciel, that was almost it. At first I tried to do it using the Copy Files phase, but the pbxcp program called by this phase did not resolve the links either, even though there is some switch called -resolve-src-symlinks . I ended up adding a Run Script

Atomic `ln -sf` in python (symlink overwriting exsting file)

只谈情不闲聊 提交于 2019-12-02 16:48:11
问题 I want create a symlink, overwriting an existing file or symlink if needed. I've discovered that os.path.exists only returns True for non-broken symlinks, so I'm guessing that any test must also include os.path.lexists. What is the most atomic way to implement ln -sf in python? (Ie, preventing a file being created by another process between deletion and symlink creation) Differentiation: This question doesn't specify the atomic requirement 回答1: This code tries to minimise the possibilities

Atomic `ln -sf` in python (symlink overwriting exsting file)

巧了我就是萌 提交于 2019-12-02 11:21:39
I want create a symlink, overwriting an existing file or symlink if needed. I've discovered that os.path.exists only returns True for non-broken symlinks, so I'm guessing that any test must also include os.path.lexists . What is the most atomic way to implement ln -sf in python? (Ie, preventing a file being created by another process between deletion and symlink creation) Differentiation: This question doesn't specify the atomic requirement This code tries to minimise the possibilities for race conditions: import os import tempfile def symlink_force(target, link_name): ''' Create a symbolic

Opening a file which is a symlink in Python

流过昼夜 提交于 2019-12-01 23:53:45
I have some python code that opens a file to read it like so... with open("file.txt") as f: print(f.read()) On MacOS, if file.txt is a symlink - Python will follow the symlink and read the target file. However, on Windows it does not do this - how can I achieve this? (Using Python version 3.6.5 and Windows 10) Steps to reproduce. Create FileA.txt in DirectoryA which is above DirectoryB Inside DirectoryB , Run mlink FileA.txt "../FileA.txt" Run a Python script which attempts to read and print from the FileA.txt link in DirectoryB Expected Behaviour: The contents of FileA.txt inside DirectoryA

How to use reuse softlinks created on Mac in Windows 8

家住魔仙堡 提交于 2019-12-01 23:31:00
I have few softlinks, says 1000 images which i have created in MacBook Pro which i am using in my iOS Apps. Now i am porting the same app in Windows 8 phone app, so i want to reuse the same Softlink in Windows phone 8 apps as well, so how can i use that ? I have tried to open the softlink in Windows 8 machine, but it says that the "File format is not supported". I have both the original file and the softlink in my Windows machine. Is there anyother way that i can reuse the same soft link ? if NOT what is the best approach that i can follow. EDIT Ok, here is some more info on this : In MacBook

Parsing Shortcuts in Powershell

ε祈祈猫儿з 提交于 2019-12-01 21:15:59
I have some code which is trying to make a copy of a directory which contains shortcuts: # Create a directory to store the files in mkdir "D:\backup-temp\website.com files\" # Search for shortcuts so that we can exclude them from the copy $DirLinks = Get-ChildItem "\\web1\c$\Web Sites\website\" -Recurse | ? { $_.Attributes -like "*ReparsePoint*" } | % { $_.FullName } # Execute the copy cp -recurse -Exclude $DirLinks "\\web1\c$\Web Sites\website\*" "D:\backup-temp\website.com files\" But when I execute the script I get the following error: Copy-Item : The symbolic link cannot be followed