dialogs.nim and osinfo_win.nim compile again

This commit is contained in:
Araq 2012-07-10 01:21:04 +02:00
commit 759d372863
2 changed files with 18 additions and 12 deletions

View file

@ -65,13 +65,13 @@ proc ChooseFileToOpen*(window: PWindow, root: string = ""): string =
var var
opf: TOPENFILENAME opf: TOPENFILENAME
buf: array [0..2047, char] buf: array [0..2047, char]
opf.lStructSize = sizeof(opf) opf.lStructSize = sizeof(opf).int32
if root.len > 0: if root.len > 0:
opf.lpstrInitialDir = root opf.lpstrInitialDir = root
opf.lpstrFilter = "All Files\0*.*\0\0" opf.lpstrFilter = "All Files\0*.*\0\0"
opf.flags = OFN_FILEMUSTEXIST opf.flags = OFN_FILEMUSTEXIST
opf.lpstrFile = buf opf.lpstrFile = buf
opf.nMaxFile = sizeof(buf) opf.nMaxFile = sizeof(buf).int32
var res = GetOpenFileName(addr(opf)) var res = GetOpenFileName(addr(opf))
if res != 0: if res != 0:
result = $buf result = $buf
@ -100,13 +100,13 @@ proc ChooseFilesToOpen*(window: PWindow, root: string = ""): seq[string] =
var var
opf: TOPENFILENAME opf: TOPENFILENAME
buf: array [0..2047*4, char] buf: array [0..2047*4, char]
opf.lStructSize = sizeof(opf) opf.lStructSize = sizeof(opf).int32
if root.len > 0: if root.len > 0:
opf.lpstrInitialDir = root opf.lpstrInitialDir = root
opf.lpstrFilter = "All Files\0*.*\0\0" opf.lpstrFilter = "All Files\0*.*\0\0"
opf.flags = OFN_FILEMUSTEXIST or OFN_ALLOWMULTISELECT or OFN_EXPLORER opf.flags = OFN_FILEMUSTEXIST or OFN_ALLOWMULTISELECT or OFN_EXPLORER
opf.lpstrFile = buf opf.lpstrFile = buf
opf.nMaxFile = sizeof(buf) opf.nMaxFile = sizeof(buf).int32
var res = GetOpenFileName(addr(opf)) var res = GetOpenFileName(addr(opf))
result = @[] result = @[]
if res != 0: if res != 0:
@ -161,13 +161,13 @@ proc ChooseFileToSave*(window: PWindow, root: string = ""): string =
var var
opf: TOPENFILENAME opf: TOPENFILENAME
buf: array [0..2047, char] buf: array [0..2047, char]
opf.lStructSize = sizeof(opf) opf.lStructSize = sizeof(opf).int32
if root.len > 0: if root.len > 0:
opf.lpstrInitialDir = root opf.lpstrInitialDir = root
opf.lpstrFilter = "All Files\0*.*\0\0" opf.lpstrFilter = "All Files\0*.*\0\0"
opf.flags = OFN_OVERWRITEPROMPT opf.flags = OFN_OVERWRITEPROMPT
opf.lpstrFile = buf opf.lpstrFile = buf
opf.nMaxFile = sizeof(buf) opf.nMaxFile = sizeof(buf).int32
var res = GetSaveFileName(addr(opf)) var res = GetSaveFileName(addr(opf))
if res != 0: if res != 0:
result = $buf result = $buf

View file

@ -67,7 +67,7 @@ type
SuiteMask*: int SuiteMask*: int
ProductType*: int ProductType*: int
TPartitionInfo* = tuple[FreeSpace, TotalSpace: filetime] TPartitionInfo* = tuple[FreeSpace, TotalSpace: Tfiletime]
const const
# SuiteMask - VersionInfo.SuiteMask # SuiteMask - VersionInfo.SuiteMask
@ -157,7 +157,7 @@ proc GlobalMemoryStatusEx*(lpBuffer: var TMEMORYSTATUSEX){.stdcall, dynlib: "ker
proc getMemoryInfo*(): TMemoryInfo = proc getMemoryInfo*(): TMemoryInfo =
## Retrieves memory info ## Retrieves memory info
var statex: TMEMORYSTATUSEX var statex: TMEMORYSTATUSEX
statex.dwLength = sizeof(statex) statex.dwLength = sizeof(statex).int32
GlobalMemoryStatusEx(statex) GlobalMemoryStatusEx(statex)
result.MemoryLoad = statex.dwMemoryLoad result.MemoryLoad = statex.dwMemoryLoad
@ -180,7 +180,7 @@ proc GetModuleHandleA*(lpModuleName: cstring): int{.stdcall,
proc getVersionInfo*(): TVersionInfo = proc getVersionInfo*(): TVersionInfo =
## Retrieves operating system info ## Retrieves operating system info
var osvi: TOSVERSIONINFOEX var osvi: TOSVERSIONINFOEX
osvi.dwOSVersionInfoSize = sizeof(osvi) osvi.dwOSVersionInfoSize = sizeof(osvi).int32
discard GetVersionEx(osvi) discard GetVersionEx(osvi)
result.majorVersion = osvi.dwMajorVersion result.majorVersion = osvi.dwMajorVersion
result.minorVersion = osvi.dwMinorVersion result.minorVersion = osvi.dwMinorVersion
@ -367,7 +367,13 @@ proc `$`*(osvi: TVersionInfo): string =
proc getFileSize*(file: string): biggestInt = proc getFileSize*(file: string): biggestInt =
var fileData: TWIN32_FIND_DATA var fileData: TWIN32_FIND_DATA
var hFile = FindFirstFileA(file, fileData)
when useWinUnicode:
var aa = allocWideCString(file)
var hFile = FindFirstFileW(aa, fileData)
dealloc aa
else:
var hFile = FindFirstFileA(file, fileData)
if hFile == INVALID_HANDLE_VALUE: if hFile == INVALID_HANDLE_VALUE:
raise newException(EIO, $GetLastError()) raise newException(EIO, $GetLastError())
@ -376,12 +382,12 @@ proc getFileSize*(file: string): biggestInt =
proc GetDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller, proc GetDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller,
lpTotalNumberOfBytes, lpTotalNumberOfBytes,
lpTotalNumberOfFreeBytes: var filetime): WINBOOL{. lpTotalNumberOfFreeBytes: var TFiletime): WINBOOL{.
stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".} stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".}
proc getPartitionInfo*(partition: string): TPartitionInfo = proc getPartitionInfo*(partition: string): TPartitionInfo =
## Retrieves partition info, for example ``partition`` may be ``"C:\"`` ## Retrieves partition info, for example ``partition`` may be ``"C:\"``
var FreeBytes, TotalBytes, TotalFreeBytes: filetime var FreeBytes, TotalBytes, TotalFreeBytes: TFiletime
var res = GetDiskFreeSpaceEx(r"C:\", FreeBytes, TotalBytes, var res = GetDiskFreeSpaceEx(r"C:\", FreeBytes, TotalBytes,
TotalFreeBytes) TotalFreeBytes)
return (FreeBytes, TotalBytes) return (FreeBytes, TotalBytes)