OpenTTD Source: src/os/windows/win32.cpp File Reference

OpenTTD Source 13.2.1

Data Structures | Macros | Functions | Variables
win32.cpp File Reference
`#include "../../stdafx.h"`
`#include "../../debug.h"`
`#include "../../gfx_func.h"`
`#include "../../textbuf_gui.h"`
`#include "../../fileio_func.h"`
`#include <windows.h>`
`#include <fcntl.h>`
`#include <mmsystem.h>`
`#include <regstr.h>`
`#include <shlobj.h>`
`#include <shellapi.h>`
`#include "win32.h"`
`#include "../../fios.h"`
`#include "../../core/alloc_func.hpp"`
`#include "../../openttd.h"`
`#include "../../core/random_func.hpp"`
`#include "../../string_func.h"`
`#include "../../crashlog.h"`
`#include <errno.h>`
`#include <sys/stat.h>`
`#include "../../language.h"`
`#include "../../thread.h"`
`#include <array>`
`#include "../../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | DIR

## Macros
#define | NO_SHOBJIDL_SORTDIRECTION
#define | SORT_DIGITSASNUMBERS 0x00000008
#define | LINGUISTIC_IGNORECASE 0x00000010

## Functions
bool | MyShowCursor (bool show, bool toggle)
void | ShowOSErrorBox (const char *buf, bool system)
void | OSOpenBrowser (const char *url)
static DIR * | dir_calloc ()
static void | dir_free (DIR *d)
DIR * | opendir (const wchar_t *path)
struct dirent * | readdir (DIR *d)
int | closedir (DIR *d)
bool | FiosIsRoot (const char *file)
void | FiosGetDrives (FileList &file_list)
bool | FiosIsValidFile (const char *path, const struct dirent *ent, struct stat *sb)
bool | FiosIsHiddenFile (const struct dirent *ent)
bool | FiosGetDiskFreeSpace (const char *path, uint64 *tot)
static int | ParseCommandLine (char *line, char **argv, int max_argc)
void | CreateConsole ()
static INT_PTR CALLBACK | HelpDialogFunc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
| Callback function to handle the window.
void | ShowInfo (const char *str)
int APIENTRY | WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
char * | getcwd (char *buf, size_t size)
void | DetermineBasePaths (const char *exe)
bool | GetClipboardContents (char *buffer, const char *last)
| Try to retrieve the current clipboard contents. More...
std::string | FS2OTTD (const std::wstring &name)
| Convert to OpenTTD's encoding from a wide string. More...
std::wstring | OTTD2FS (const std::string &name)
| Convert from OpenTTD's encoding to a wide string. More...
char * | convert_from_fs (const wchar_t *name, char *utf8_buf, size_t buflen)
| Convert to OpenTTD's encoding from that of the environment in UNICODE. More...
wchar_t * | convert_to_fs (const char *name, wchar_t *system_buf, size_t buflen)
| Convert from OpenTTD's encoding to that of the environment in UNICODE. More...
const char * | GetCurrentLocale (const char *)
| Determine the current user's locale.
void | Win32SetCurrentLocaleName (const char *iso_code)
int | OTTDStringCompare (const char *s1, const char *s2)
void | SetCurrentThreadName (const char *)
| Name the thread this function is called on for the debugger. More...

## Variables
static bool | _has_console
static bool | _cursor_disable = true
static bool | _cursor_visible = true
static DIR | _global_dir
static LONG | _global_dir_is_in_use = false
static const char * | _help_msg
| Temporary pointer to get the help message to the window.
std::string | _config_file
| Configuration file of OpenTTD.
static WCHAR | _cur_iso_locale [16] = L""

## Detailed Description

Implementation of MS Windows system calls

Definition in file win32.cpp.

## Function Documentation

## ◆ convert_from_fs()

char* convert_from_fs | ( | const wchar_t * | name,
|  | char * | utf8_buf,
|  | size_t | buflen
| ) |  |

Convert to OpenTTD's encoding from that of the environment in UNICODE.

OpenTTD encoding is UTF8, local is wide.

Parameters

  name | pointer to a valid string that will be converted
  utf8_buf | pointer to a valid buffer that will receive the converted string
  buflen | length in characters of the receiving buffer

Returns
  pointer to utf8_buf. If conversion fails the string is of zero-length

Definition at line 580 of file win32.cpp.

Referenced by HandleIMEComposition().

## ◆ convert_to_fs()

wchar_t* convert_to_fs | ( | const char * | name,
|  | wchar_t * | system_buf,
|  | size_t | buflen
| ) |  |

Convert from OpenTTD's encoding to that of the environment in UNICODE.

OpenTTD encoding is UTF8, local is wide.

Parameters

  name | pointer to a valid string that will be converted
  system_buf | pointer to a valid wide-char buffer that will receive the converted string
  buflen | length in wide characters of the receiving buffer
  console_cp | convert to the console encoding instead of the normal system encoding.

Returns
  pointer to system_buf. If conversion fails the string is of zero-length

Definition at line 600 of file win32.cpp.

Referenced by HelpDialogFunc(), and HFontFromFont().

## ◆ FS2OTTD()

std::string FS2OTTD | ( | const std::wstring & | name | ) |

Convert to OpenTTD's encoding from a wide string.

OpenTTD internal encoding is UTF8.

Parameters

  name | valid string that will be converted (local, or wide)

Returns
  converted string; if failed string is of zero-length

See also
  the current code-page comes from video\win32_v.cpp, event-notification WM_INPUTLANGCHANGE

Definition at line 542 of file win32.cpp.

References AllocaM.

Referenced by HandleIMEComposition(), DLSFile::LoadFile(), and NetworkAddress::Resolve().

## ◆ GetClipboardContents()

bool GetClipboardContents | ( | char * | buffer,
|  | const char * | last
| ) |  |

Try to retrieve the current clipboard contents.

Note
  OS-specific function.

Parameters

  buffer | Clipboard content.
  last | The pointer to the last element of the destination buffer

Returns
  True if some text could be retrieved.

Definition at line 511 of file win32.cpp.

References strecpy().

Referenced by Textbuf::InsertClipboard().

## ◆ OTTD2FS()

std::wstring OTTD2FS | ( | const std::string & | name | ) |

Convert from OpenTTD's encoding to a wide string.

OpenTTD internal encoding is UTF8.

Parameters

  name | valid string that will be converted (UTF8)
  console_cp | convert to the console encoding instead of the normal system encoding.

Returns
  converted string; if failed string is of zero-length

Definition at line 560 of file win32.cpp.

References AllocaM.

Referenced by FileExists(), and IniFile::SaveToDisk().

## ◆ SetCurrentThreadName()

void SetCurrentThreadName | ( | const char * | name | ) |

Name the thread this function is called on for the debugger.

Parameters

  name | Name to set for the thread..

Definition at line 721 of file win32.cpp.