NTFS reparse points

2005-11-03 Thread Stanislaw Findeisen
I want to create a reparse point on NTFS (any).

Here 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/reparse_points.asp)
 
I read: "reparse points are used to implement NTFS file system links". 
Here 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/hard_links_and_junctions.asp)
 
I read: "Soft links are implemented through reparse points".

However I can't see FILE_ATTRIBUTE_REPARSE_POINT turned on in any file / 
directory shortcuts I create. In fact the only attribute set in 
shortcuts created using Windows Explorer is FILE_ATTRIBUTE_ARCHIVE. (I 
am using GetFileAttributes() to examine this.)

The questions are:

(1) Why is that so?
(2) Does anybody have any idea (sample code?) on how to create a reparse 
point (the simpler, the better) using Python?

I am using Windows 2000 Professional, Python 2.4 and Mark Hammond's 
Python for Windows Extensions build 204.

Thank you.

+---+
| When replying, please replace "my_initials" in the|
| From: address field with my initials - that is, "SF". |
+---+

-- 
 http://www.nglogic.com
 Enter through the narrow gate! (Mt 7:13-14)
-- 
http://mail.python.org/mailman/listinfo/python-list


Unicode-aware file shortcuts in Windows

2005-09-16 Thread Stanislaw Findeisen
Does anyone know how to create file shortcuts in Windows?

The only way I know is like:

---

import win32com.client

wScriptShellObject = win32com.client.Dispatch("WScript.Shell")
shortcutName = unicode("shortcut.lnk", "utf8")
shortcut = wScriptShellObject.CreateShortcut(shortcutName)
shortcut.TargetPath = 
shortcut.Save()

---

Unfortunately, this causes problems with Unicode characters:

(1) If there are Unicode characters in target file name, not all of them 
get correctly copied to the shortcut's "target" attribute, thus 
producing an invalid shortcut.

(2) If there are Unicode characters in shortcut name, not all of them 
get correctly copied, thus producing a shortcut with a name different 
than desired.

(3) If there are Unicode characters somewhere in the path to the 
shortcut itself (above the shortcut name component), then they also get 
corrupted, which effects in an invalid (non-existent) path and errors 
like this one:

---

E:\Documents and Settings\Staszek\Progs\Python-Windows\test_1>cf.py
Traceback (most recent call last):
   File "E:\Documents and 
Settings\Staszek\Progs\Python-Windows\test_1\cf.py", line 7, in ?
 shortcut.Save()
   File ">", line 2, in Save
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 
'WshShortcut.Save', 'Unable to save shortcut "E:\\Documents and 
Settings\\Staszek\\Progs\\Python-Windows\\test_1\\Te\x9a\xed me c\xfd 
z\xf3lazcseL\\link do vecer Z\xd3LAKe e\x9a\xed bla.lnk".', None, 0, 
-2147024893), None)

---

The original path to shortcut file referenced in error description above 
contains Polish and Czech characters, and it was:

---

E:\Documents and Settings\Staszek\Progs\Python-Windows\test_1\Těší mě čý 
żółąźćśęŁ\link do večer ŻÓŁĄKę ěší bla.lnk

---

As it can be seen, some of those national characters in the error 
description string are escaped using the \x.. sequence, while others are 
simply "flatten" (like first "e" in "Te\x9a\xed", or "lazcse").

So it seems as if WScript.Shell object in Python didn't fully support 
Unicode?... Or perhaps it does, but one has to know how to activate it.

Any help would be appreciated.

I am using standard Windows console cmd.exe in Windows 2000, Python 2.4, 
and Mark Hammond's Python for Windows Extensions build 204.

+---+
| When replying, please replace "my_initials" in the|
| From: address field with my initials - that is, "SF". |
+---+

-- 
 http://www.nglogic.com
 Enter through the narrow gate! (Mt 7:13-14)
-- 
http://mail.python.org/mailman/listinfo/python-list