ZenLib
OS_Utils.h
Go to the documentation of this file.
1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2  *
3  * Use of this source code is governed by a zlib-style license that can
4  * be found in the License.txt file in the root of the source tree.
5  */
6 
7 //---------------------------------------------------------------------------
8 #ifndef ZenOS_UtilsH
9 #define ZenOS_UtilsH
10 //---------------------------------------------------------------------------
11 
12 //---------------------------------------------------------------------------
13 #include "ZenLib/Ztring.h"
14 //---------------------------------------------------------------------------
15 
16 //---------------------------------------------------------------------------
17 #ifdef WINDOWS_UWP
18 #include <wrl.h>
19 #include <windows.foundation.h>
20 #include <windows.storage.h>
21 #endif
22 //---------------------------------------------------------------------------
23 
24 namespace ZenLib
25 {
26 
27 //***************************************************************************
28 // OS Information
29 //***************************************************************************
30 
31 //---------------------------------------------------------------------------
32 bool IsWin9X ();
33 // Execute
34 //***************************************************************************
35 
36 void Shell_Execute(const Ztring &ToExecute);
37 
38 //***************************************************************************
39 // File names
40 //***************************************************************************
41 
42 std::string FileName_To_Native(const Ztring &File_Name);
43 Ztring FileName_From_Native(const char* File_Name);
44 
45 //***************************************************************************
46 // Directorues
47 //***************************************************************************
48 
49 Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption);
50 
51 //***************************************************************************
52 // WinRT Helpers
53 //***************************************************************************
54 #ifdef WINDOWS_UWP
55 template <typename T>
56 inline HRESULT Await(const Microsoft::WRL::ComPtr<T> &Operation)
57 {
58  if (!Operation)
59  return E_POINTER;
60 
61  Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncInfo> Info;
62  HRESULT Result=Operation.As(&Info);
63  if (FAILED(Result))
64  return Result;
65 
66  ABI::Windows::Foundation::AsyncStatus Status;
67  while (SUCCEEDED(Result=Info->get_Status(&Status)) && Status==Started)
68  Sleep(0); //Yield
69 
70  if (FAILED(Result) || Status!=Completed) {
71  HRESULT Error_Code;
72  Result=Info->get_ErrorCode(&Error_Code);
73  if (FAILED(Result))
74  return Result;
75  return Error_Code;
76  }
77 
78  return Result;
79 }
80 
81 HRESULT Add_Item_To_FUA(Microsoft::WRL::Wrappers::HStringReference Path, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageItem> &Item);
82 HRESULT Get_File(Microsoft::WRL::Wrappers::HStringReference File_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFile> &File);
83 HRESULT Get_Folder(Microsoft::WRL::Wrappers::HStringReference Folder_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFolder> &Folder);
84 #endif
85 
86 } //namespace ZenLib
87 #endif
void Shell_Execute(const Ztring &ToExecute)
bool IsWin9X()
Definition: BitStream.h:23
Ztring FileName_From_Native(const char *File_Name)
std::string FileName_To_Native(const Ztring &File_Name)
Ztring OpenFolder_Show(void *Handle, const Ztring &Title, const Ztring &Caption)