Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make datafolder to appdata, and its linux equivalent #34

Closed
nopara73 opened this issue Sep 27, 2017 · 3 comments
Closed

Make datafolder to appdata, and its linux equivalent #34

nopara73 opened this issue Sep 27, 2017 · 3 comments
Milestone

Comments

@nopara73
Copy link
Contributor

No description provided.

@nopara73 nopara73 changed the title Make datafolder in appdata, and its linux equivalent Make datafolder to appdata, and its linux equivalent Sep 27, 2017
@wintercooled
Copy link
Contributor

I've done this with a service in Windows and Linux (and Mac) so am happy to pick this up at some point. In Windows the folder location varies by which OS it is - so I've code I can re-use here to handle this.

@nopara73
Copy link
Contributor Author

nopara73 commented Oct 18, 2017

Sounds good. Just pay attention not to conflict with Electron's stuff. It messes into the appdata folder.

For reference, this is how Stratis and NTumbleBit is going it:

        /// <summary>
        /// Finds a location of the default data directory respecting different operating system specifics.
        /// </summary>
        /// <param name="appName">Name of the node, which will be reflected in the name of the data directory.</param>
        /// <param name="network">Specification of the network the node runs on - regtest/testnet/mainnet.</param>
        private void SetDefaultDataDir(string appName, Network network)
        {
            string directory = null;

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var home = Environment.GetEnvironmentVariable("HOME");
                if (!string.IsNullOrEmpty(home))
                {
                    this.Logger.LogInformation("Using HOME environment variable for initializing application data.");
                    directory = Path.Combine(home, "." + appName.ToLowerInvariant());
                }
                else
                {
                    throw new DirectoryNotFoundException("Could not find suitable datadir");
                }
            }
            else
            {
                var localAppData = Environment.GetEnvironmentVariable("APPDATA");
                if (!string.IsNullOrEmpty(localAppData))
                {
                    this.Logger.LogInformation("Using APPDATA environment variable for initializing application data.");
                    directory = Path.Combine(localAppData, appName);
                }
                else
                {
                    throw new DirectoryNotFoundException("Could not find suitable datadir");
                }
            }

            if (!Directory.Exists(directory))
                Directory.CreateDirectory(directory);

            directory = Path.Combine(directory, network.Name);
            if (!Directory.Exists(directory))
            {
                this.Logger.LogInformation("Creating data directory...");
                Directory.CreateDirectory(directory);
            }

            this.DataDir = directory;
        }

@nopara73 nopara73 added this to the Preparation milestone Oct 21, 2017
@nopara73
Copy link
Contributor Author

Done.

soosr added a commit that referenced this issue Aug 15, 2023
SuperJMN pushed a commit to SuperJMN/WalletWasabi that referenced this issue Apr 5, 2024
Add command to privacy bar to show UTXOs details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants