blob: 45450f4eb5e7883622a98da01945d289f2b421c6 (
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DirectoryUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// Defines the DirectoryUtilities type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Utilities
{
using System;
using System.IO;
/// <summary>
/// The directory utilities.
/// </summary>
public class DirectoryUtilities
{
/// <summary>
/// The get user storage path.
/// </summary>
/// <param name="isNightly">
/// The is nightly.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GetUserStoragePath(bool isNightly)
{
if (isNightly)
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HandBrake", "Nightly");
}
else
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HandBrake");
}
}
/// <summary>
/// Simple way of checking if a directory is writeable.
/// </summary>
/// <param name="dirPath">Path to check</param>
/// <returns>True if writable</returns>
public static bool IsWritable(string dirPath)
{
try
{
using (File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose))
{
}
return true;
}
catch
{
return false;
}
}
}
}
|