Skip to content

Commit

Permalink
[tvOS] Be less eager in creating the non-existent special folders (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara authored Sep 13, 2021
1 parent b2fbf3d commit fa28488
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mono/System.Private.CoreLib/src/System/Environment.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ static string CombineSearchPath(NSSearchPathDirectory searchPath, string subdire
static string CombineDocumentDirectory(string subdirectory)
{
#if TARGET_TVOS
string? path = CombineSearchPath(NSSearchPathDirectory.NSLibraryDirectory, Path.Combine("Caches", "Documents", subdirectory));
string? path = CombineSearchPath(NSSearchPathDirectory.NSLibraryDirectory, Path.Combine("Caches", "Documents"));
// Special version of CombineSearchPath which creates the path if needed.
// This isn't needed for "real" search paths which always exist, but on tvOS
// the base path is really a subdirectory we define rather than an OS directory.
// In order to not treat Directory.Exists(SpecialFolder.ApplicationData) differently
// on tvOS, guarantee that it exists by creating it here
if (!Directory.Exists (path))
Directory.CreateDirectory (path);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
path = Path.Combine(path, subdirectory);
#else
string? path = CombineSearchPath(NSSearchPathDirectory.NSDocumentDirectory, subdirectory);
#endif
Expand Down

0 comments on commit fa28488

Please sign in to comment.