summaryrefslogtreecommitdiff
path: root/Runtime/Export/Windows/WindowsDirectory.txt
blob: b0342793695347062405ad2e06a91e148511a11b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
C++RAW

#include "UnityPrefix.h"
#include "Runtime/Mono/MonoManager.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Scripting/ScriptingExportUtility.h"
#include "Runtime/Utilities/File.h"

#if UNITY_EDITOR
#include "Editor/Src/ProjectWizardUtility.h"
#endif

#if UNITY_METRO
#include "PlatformDependent/MetroPlayer/MetroUtils.h"
#endif

using namespace Unity;

using namespace std;

CSRAW
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using UnityEngineInternal;

namespace UnityEngine.Windows
{
CONDITIONAL UNITY_WINRT_API
CLASS Directory
	CUSTOM_PROP public static string temporaryFolder
	{
	#if UNITY_METRO
		return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->TemporaryFolder->Path->Data()));
	#else
	#if UNITY_WP8
		string path = ConvertStringToUtf8(Platform::String::Concat(Windows::Storage::ApplicationData::Current->LocalFolder->Path, L"\\Temp")->Data());
	#else
		string path = GetProjectPath() + "/TempState";
	#endif
		if (IsDirectoryCreated(path) == false) CreateDirectory(path);
		return scripting_string_new(path);
	#endif
	}
	CUSTOM_PROP public static string localFolder
	{
	#if UNITY_WINRT
		return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data()));
	#else
		string path = GetProjectPath() + "/LocalState";
		if (IsDirectoryCreated(path) == false) CreateDirectory(path);
		return scripting_string_new(path);
	#endif
	}
	CUSTOM_PROP public static string roamingFolder
	{
	#if UNITY_METRO
		return scripting_string_new(ConvertStringToUtf8(Windows::Storage::ApplicationData::Current->RoamingFolder->Path->Data()));
	#else
	#if UNITY_WP8
	string path = ConvertStringToUtf8(Platform::String::Concat(Windows::Storage::ApplicationData::Current->LocalFolder->Path, L"\\Roaming")->Data());
	#else
		string path = GetProjectPath() + "/RoamingState";
	#endif
		if (IsDirectoryCreated(path) == false) CreateDirectory(path);
		return scripting_string_new(path);
	#endif
	}
	CUSTOM public static void CreateDirectory(string path)
	{
		CreateDirectory(path.AsUTF8());
	}
	CUSTOM public static bool Exists(string path)
	{
		return IsDirectoryCreated(path.AsUTF8());
	}
	CUSTOM public static void Delete(string path)
	{
		if (IsDirectoryCreated(path.AsUTF8()))
			DeleteFileOrDirectory(path.AsUTF8());
	}
CSRAW
END

CSRAW
}