5526 |
5526 |
5527 linkInfoOf:aPathName |
5527 linkInfoOf:aPathName |
5528 "return some object filled with info for the file 'aPathName'; |
5528 "return some object filled with info for the file 'aPathName'; |
5529 the info (for which corresponding access methods are understood by |
5529 the info (for which corresponding access methods are understood by |
5530 the returned object) is: |
5530 the returned object) is: |
5531 type - a symbol giving the files type |
5531 type - a symbol giving the files type |
5532 mode - numeric access mode |
5532 mode - numeric access mode |
5533 uid - owners user id |
5533 uid - owners user id |
5534 gid - owners group id |
5534 gid - owners group id |
5535 size - files size |
5535 size - files size |
5536 id - files number (i.e. inode number) |
5536 id - files number (i.e. inode number) |
5537 accessed - last access time (as Timestamp) |
5537 accessed - last access time (as Timestamp) |
5538 modified - last modification time (as Timestamp) |
5538 modified - last modification time (as Timestamp) |
5539 statusChanged - last status change time (as Timestamp) |
5539 statusChanged - last status change time (as Timestamp) |
5540 alternativeName - (windows only:) the MSDOS name of the file |
5540 alternativeName - (windows only:) the MSDOS name of the file |
5541 |
5541 |
5542 Some of the fields may be returned as nil on systems which do not provide |
5542 Some of the fields may be returned as nil on systems which do not provide |
5543 all of the information. |
5543 all of the information. |
5544 Return nil if such a file does not exist. |
5544 Return nil if such a file does not exist. |
5545 |
5545 |
5562 WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; |
5562 WIN32_FILE_ATTRIBUTE_DATA fileAttributeData; |
5563 unsigned INT ino; |
5563 unsigned INT ino; |
5564 wchar_t _aPathName[MAXPATHLEN+1]; |
5564 wchar_t _aPathName[MAXPATHLEN+1]; |
5565 |
5565 |
5566 if (__isStringLike(aPathName)) { |
5566 if (__isStringLike(aPathName)) { |
5567 int i; |
5567 int i; |
5568 int l = __stringSize(aPathName); |
5568 int l = __stringSize(aPathName); |
5569 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5569 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5570 |
5570 |
5571 for (i=0; i<l; i++) { |
5571 for (i=0; i<l; i++) { |
5572 _aPathName[i] = __stringVal(aPathName)[i]; |
5572 _aPathName[i] = __stringVal(aPathName)[i]; |
5573 } |
5573 } |
5574 _aPathName[i] = 0; |
5574 _aPathName[i] = 0; |
5575 } else if (__isUnicode16String(aPathName)) { |
5575 } else if (__isUnicode16String(aPathName)) { |
5576 int i; |
5576 int i; |
5577 int l = __unicode16StringSize(aPathName); |
5577 int l = __unicode16StringSize(aPathName); |
5578 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5578 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5579 |
5579 |
5580 for (i=0; i<l; i++) { |
5580 for (i=0; i<l; i++) { |
5581 _aPathName[i] = __unicode16StringVal(aPathName)[i]; |
5581 _aPathName[i] = __unicode16StringVal(aPathName)[i]; |
5582 } |
5582 } |
5583 _aPathName[i] = 0; |
5583 _aPathName[i] = 0; |
5584 } else |
5584 } else |
5585 goto badArgument; |
5585 goto badArgument; |
5586 |
5586 |
5587 #ifdef DO_WRAP_CALLS |
5587 #ifdef DO_WRAP_CALLS |
5588 { |
5588 { |
5589 do { |
5589 do { |
5590 __threadErrno = 0; |
5590 __threadErrno = 0; |
5591 result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData); |
5591 result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData); |
5592 } while (!result && (__threadErrno == EINTR)); |
5592 } while (!result && (__threadErrno == EINTR)); |
5593 } |
5593 } |
5594 #else |
5594 #else |
5595 result = GetFileAttributesExW(_aPathName, GetFileExInfoStandard, &fileAttributeData); |
5595 result = GetFileAttributesExW(_aPathName, GetFileExInfoStandard, &fileAttributeData); |
5596 if (!result) { |
5596 if (!result) { |
5597 __threadErrno = __WIN32_ERR(GetLastError()); |
5597 __threadErrno = __WIN32_ERR(GetLastError()); |
5598 } |
5598 } |
5599 #endif |
5599 #endif |
5600 |
5600 |
5601 if (!result) { |
5601 if (!result) { |
5602 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5602 @global(LastErrorNumber) = __mkSmallInteger(__threadErrno); |
5603 } else { |
5603 } else { |
5604 id = __mkSmallInteger(0); /* could get it by opening ... */ |
5604 id = __mkSmallInteger(0); /* could get it by opening ... */ |
5605 size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh); |
5605 size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh); |
5606 |
5606 |
5607 // if (fileAttributeData.cFileName[0] != '\0') { |
5607 // if (fileAttributeData.cFileName[0] != '\0') { |
5608 // bcopy(fileAttributeData.cFileName, fileNameBuffer, MAXPATHLEN*sizeof(wchar_t)); |
5608 // bcopy(fileAttributeData.cFileName, fileNameBuffer, MAXPATHLEN*sizeof(wchar_t)); |
5609 // fileNameBuffer[MAXPATHLEN] = '\0'; |
5609 // fileNameBuffer[MAXPATHLEN] = '\0'; |
5610 // fileName = __MKU16STRING(fileNameBuffer); /* FULL name */ |
5610 // fileName = __MKU16STRING(fileNameBuffer); /* FULL name */ |
5614 // bcopy(fileAttributeData.cAlternateFileName, alternativeFileNameBuffer, 14*sizeof(wchar_t)); |
5614 // bcopy(fileAttributeData.cAlternateFileName, alternativeFileNameBuffer, 14*sizeof(wchar_t)); |
5615 // alternativeFileNameBuffer[14] = '\0'; |
5615 // alternativeFileNameBuffer[14] = '\0'; |
5616 // alternativeName = __MKU16STRING(alternativeFileNameBuffer); /* DOS name */ |
5616 // alternativeName = __MKU16STRING(alternativeFileNameBuffer); /* DOS name */ |
5617 // } |
5617 // } |
5618 |
5618 |
5619 /* |
5619 /* |
5620 * simulate access bits |
5620 * simulate access bits |
5621 */ |
5621 */ |
5622 if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
5622 if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
5623 modeBits = 0444; |
5623 modeBits = 0444; |
5624 } else { |
5624 } else { |
5625 modeBits = 0666; |
5625 modeBits = 0666; |
5626 } |
5626 } |
5627 |
5627 |
5628 if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
5628 if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
5629 type = @symbol(directory); |
5629 type = @symbol(directory); |
5630 modeBits = 0777; /* executable and WRITABLE - refer to comment in #isWritable: */ |
5630 modeBits = 0777; /* executable and WRITABLE - refer to comment in #isWritable: */ |
5631 } else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { |
5631 } else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { |
5632 type = @symbol(symbolicLink); |
5632 type = @symbol(symbolicLink); |
5633 modeBits = 0777; /* even in UNIX symlinks have 0777 */ |
5633 modeBits = 0777; /* even in UNIX symlinks have 0777 */ |
5634 } else { |
5634 } else { |
5635 type = @symbol(regular); |
5635 type = @symbol(regular); |
5636 } |
5636 } |
5637 |
5637 |
5638 mode = __mkSmallInteger(modeBits); |
5638 mode = __mkSmallInteger(modeBits); |
5639 |
5639 |
5640 cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime); |
5640 cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime); |
5641 aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime); |
5641 aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime); |
5642 mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime); |
5642 mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime); |
5643 } |
5643 } |
5644 |
5644 |
5645 badArgument: ; |
5645 badArgument: ; |
5646 %}. |
5646 %}. |
5647 |
5647 |
5648 (aPathName endsWith:'.lnk') ifTrue:[ |
5648 (aPathName endsWith:'.lnk') ifTrue:[ |
5649 type := #symbolicLink. |
5649 type := #symbolicLink. |
5650 "/ now done lazyly in FileStatusInfo, when the path is accessed |
5650 "/ now done lazyly in FileStatusInfo, when the path is accessed |
5651 "/ path := self getLinkTarget:aPathName. |
5651 "/ path := self getLinkTarget:aPathName. |
5652 ]. |
5652 ]. |
5653 |
5653 |
5654 mode isNil ifTrue:[ |
5654 mode isNil ifTrue:[ |
5655 (self isDirectory:aPathName) ifTrue:[ |
5655 (self isDirectory:aPathName) ifTrue:[ |
5656 "/ the code above fails for root directories (these do not exist). |
5656 "/ the code above fails for root directories (these do not exist). |
5657 "/ simulate here |
5657 "/ simulate here |
5658 mode := 8r777. |
5658 mode := 8r777. |
5659 type := #directory. |
5659 type := #directory. |
5660 uid := gid := 0. |
5660 uid := gid := 0. |
5661 size := 0. |
5661 size := 0. |
5662 id := 0. |
5662 id := 0. |
5663 atime := mtime := ctime := Timestamp now. |
5663 atime := mtime := ctime := Timestamp now. |
5664 ]. |
5664 ]. |
5665 ]. |
5665 ]. |
5666 mode notNil ifTrue:[ |
5666 mode notNil ifTrue:[ |
5667 atime isNil ifTrue:[ |
5667 atime isNil ifTrue:[ |
5668 atime := Timestamp new fromOSTime:aOsTime. |
5668 atime := Timestamp new fromOSTime:aOsTime. |
5669 ]. |
5669 ]. |
5670 mtime isNil ifTrue:[ |
5670 mtime isNil ifTrue:[ |
5671 mtime := Timestamp new fromOSTime:mOsTime. |
5671 mtime := Timestamp new fromOSTime:mOsTime. |
5672 ]. |
5672 ]. |
5673 ctime isNil ifTrue:[ |
5673 ctime isNil ifTrue:[ |
5674 ctime := Timestamp new fromOSTime:cOsTime. |
5674 ctime := Timestamp new fromOSTime:cOsTime. |
5675 ]. |
5675 ]. |
5676 fileName notNil ifTrue:[ |
5676 fileName notNil ifTrue:[ |
5677 fileName := fileName asSingleByteStringIfPossible |
5677 fileName := fileName asSingleByteStringIfPossible |
5678 ]. |
5678 ]. |
5679 alternativeName notNil ifTrue:[ |
5679 alternativeName notNil ifTrue:[ |
5680 alternativeName := alternativeName asSingleByteStringIfPossible |
5680 alternativeName := alternativeName asSingleByteStringIfPossible |
5681 ]. |
5681 ]. |
5682 info := FileStatusInfo |
5682 info := FileStatusInfo |
5683 type:type |
5683 type:type |
5684 mode:mode |
5684 mode:mode |
5685 uid:uid |
5685 uid:uid |
5686 gid:gid |
5686 gid:gid |
5687 size:size |
5687 size:size |
5688 id:id |
5688 id:id |
5689 accessed:atime |
5689 accessed:atime |
5690 modified:mtime |
5690 modified:mtime |
5691 created:ctime |
5691 created:ctime |
5692 sourcePath:aPathName |
5692 sourcePath:aPathName |
5693 fullName:fileName |
5693 fullName:fileName |
5694 alternativeName:alternativeName. |
5694 alternativeName:alternativeName. |
5695 ^ info |
5695 ^ info |
5696 ]. |
5696 ]. |
5697 ^ nil |
5697 ^ nil |
5698 |
5698 |
5699 " |
5699 " |
5700 OperatingSystem linkInfoOf:'c:\windows' |
5700 OperatingSystem linkInfoOf:'c:\windows' |
5863 |
5863 |
5864 |error| |
5864 |error| |
5865 |
5865 |
5866 %{ |
5866 %{ |
5867 if (__isStringLike(aPathName)) { |
5867 if (__isStringLike(aPathName)) { |
5868 char nameBuffer[MAXPATHLEN + 1]; |
5868 char nameBuffer[MAXPATHLEN + 1]; |
5869 char nameBuffer2[MAXPATHLEN + 1]; |
5869 char nameBuffer2[MAXPATHLEN + 1]; |
5870 char *returnedName = NULL; |
5870 char *returnedName = NULL; |
5871 int rslt; |
5871 int rslt; |
5872 |
5872 |
5873 #ifdef DO_WRAP_CALLS |
5873 #ifdef DO_WRAP_CALLS |
5874 char _aPathName[MAXPATHLEN+1]; |
5874 char _aPathName[MAXPATHLEN+1]; |
5875 |
5875 |
5876 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5876 strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
5877 do { |
5877 do { |
5878 __threadErrno = 0; |
5878 __threadErrno = 0; |
5879 rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL); |
5879 rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL); |
5880 } while ((rslt < 0) && (__threadErrno == EINTR)); |
5880 } while ((rslt < 0) && (__threadErrno == EINTR)); |
5881 #else |
5881 #else |
5882 rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL); |
5882 rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL); |
5883 #endif |
5883 #endif |
5884 returnedName = nameBuffer; |
5884 returnedName = nameBuffer; |
5885 |
5885 |
5886 if (rslt > 0) { |
5886 if (rslt > 0) { |
5887 #ifdef DO_WRAP_CALLS |
5887 #ifdef DO_WRAP_CALLS |
5899 } |
5899 } |
5900 __threadErrno = __WIN32_ERR(GetLastError()); |
5900 __threadErrno = __WIN32_ERR(GetLastError()); |
5901 RETURN (nil); |
5901 RETURN (nil); |
5902 } |
5902 } |
5903 if (__isUnicode16String(aPathName)) { |
5903 if (__isUnicode16String(aPathName)) { |
5904 wchar_t nameBuffer[MAXPATHLEN + 1]; |
5904 wchar_t nameBuffer[MAXPATHLEN + 1]; |
5905 wchar_t nameBuffer2[MAXPATHLEN + 1]; |
5905 wchar_t nameBuffer2[MAXPATHLEN + 1]; |
5906 wchar_t *returnedName = NULL; |
5906 wchar_t *returnedName = NULL; |
5907 int rslt; |
5907 int rslt; |
5908 wchar_t _aPathName[MAXPATHLEN+1]; |
5908 wchar_t _aPathName[MAXPATHLEN+1]; |
5909 int i, l; |
5909 int i, l; |
5910 |
5910 |
5911 l = __unicode16StringSize(aPathName); |
5911 l = __unicode16StringSize(aPathName); |
5912 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5912 if (l > MAXPATHLEN) l = MAXPATHLEN; |
5913 for (i=0; i<l; i++) { |
5913 for (i=0; i<l; i++) { |
5914 _aPathName[i] = __unicode16StringVal(aPathName)[i]; |
5914 _aPathName[i] = __unicode16StringVal(aPathName)[i]; |
5915 } |
5915 } |
5916 _aPathName[i] = 0; |
5916 _aPathName[i] = 0; |
5917 |
5917 |
5918 #ifdef DO_WRAP_CALLS |
5918 #ifdef DO_WRAP_CALLS |
5919 do { |
5919 do { |
5920 __threadErrno = 0; |
5920 __threadErrno = 0; |
5921 rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL); |
5921 rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL); |
5922 } while ((rslt < 0) && (__threadErrno == EINTR)); |
5922 } while ((rslt < 0) && (__threadErrno == EINTR)); |
5923 #else |
5923 #else |
5924 rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL); |
5924 rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL); |
5925 #endif |
5925 #endif |
5926 |
5926 |
5927 returnedName = nameBuffer; |
5927 returnedName = nameBuffer; |
5928 |
5928 |
5929 if (rslt > 0) { |
5929 if (rslt > 0) { |
7161 |
7161 |
7162 "Created: / 18-09-2007 / 16:31:23 / cg" |
7162 "Created: / 18-09-2007 / 16:31:23 / cg" |
7163 ! |
7163 ! |
7164 |
7164 |
7165 primGetLastError |
7165 primGetLastError |
7166 |
7166 %{ /* NOCONTEXT */ |
7167 <apicall: dword "GetLastError" () module: "kernel32.dll" > |
7167 DWORD e; |
|
7168 |
|
7169 e = GetLastError(); |
|
7170 RETURN(__MKUINT(e)); |
|
7171 %}. |
|
7172 |
|
7173 "/ <apicall: dword "GetLastError" () module: "kernel32.dll" > |
7168 |
7174 |
7169 " |
7175 " |
7170 self primGetLastError |
7176 self primGetLastError |
7171 " |
7177 " |
7172 ! |
7178 ! |
7173 |
7179 |
7174 primSetLastError: i |
7180 primSetLastError: i |
7175 %{ |
7181 %{ /* NOCONTEXT */ |
7176 if (__isSmallInteger(i)) { |
7182 if (__isSmallInteger(i)) { |
7177 SetLastError(__intVal(i)); |
7183 SetLastError(__intVal(i)); |
7178 RETURN(self); |
7184 RETURN(self); |
7179 } |
7185 } |
7180 %}. |
7186 %}. |
7181 self primitiveFailed. |
7187 self primitiveFailed. |
7182 |
7188 |
7183 "/ <apicall: void "SetLastError" (dword) module: "kernel32.dll" > |
7189 "/ <apicall: void "SetLastError" (dword) module: "kernel32.dll" > |
7184 |
7190 |
7185 " |
7191 " |
7186 self primSetLastError: 0 |
7192 self primSetLastError: 0 |
7187 " |
7193 " |
7188 ! |
7194 ! |
7189 |
7195 |
7190 primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString |
7196 primWritePrivateProfileString: appName keyName: keyName profileString: profString fileName: aString |
7191 |
7197 |
7850 } |
7856 } |
7851 %}. |
7857 %}. |
7852 "Keep the order as reurned by the OS" |
7858 "Keep the order as reurned by the OS" |
7853 info := OrderedDictionary new:nAdapters. |
7859 info := OrderedDictionary new:nAdapters. |
7854 nAdapters notNil ifTrue:[ |
7860 nAdapters notNil ifTrue:[ |
7855 1 to:nAdapters do:[:i | |
7861 1 to:nAdapters do:[:i | |
7856 |entry name description macAddr ipAddr| |
7862 |entry name description macAddr ipAddr| |
7857 |
7863 |
7858 entry := rawData at:i. |
7864 entry := rawData at:i. |
7859 name := entry at:1. |
7865 name := entry at:1. |
7860 "/ description := entry at:2. |
7866 "/ description := entry at:2. |
7861 macAddr := entry at:3. |
7867 macAddr := entry at:3. |
7862 "/ ipAddr := entry at:4. |
7868 "/ ipAddr := entry at:4. |
7863 info at:name put:macAddr. |
7869 info at:name put:macAddr. |
7864 ]. |
7870 ]. |
7865 ]. |
7871 ]. |
7866 ^ info |
7872 ^ info |
7867 |
7873 |
7868 " |
7874 " |
7869 OperatingSystem getNetworkMACAddresses |
7875 OperatingSystem getNetworkMACAddresses |