Aurora-Modders / AuroraLoader

A tool for discovering and safely managing Aurora mods
MIT License
10 stars 5 forks source link

When the DownloadDir contains only a single directory, assume the mod is inside it #65

Closed db48x closed 3 years ago

db48x commented 3 years ago

Gracefully handles the case where all the mod's files are inside a directory inside the zip file.

I've never written any C# before, and I don't have a compiler or development environment set up for it. @01010100b, could you check this over and see if it actually works?

01010100b commented 3 years ago

You can't use multiline code with a lambda property (the "=>" notation), you should use a standard property for that, like this:

public string ContentPath
        {
            get
            {
                var files = Directory.EnumerateFiles(DownloadPath).ToList();
                if (files.Count == 1)
                {
                    FileAttributes attr = File.GetAttributes(files[0]);
                    if (attr.HasFlag(FileAttributes.Directory))
                    {
                        return files[0];
                    }
                }
                else
                {
                    return DownloadPath;
                }

                return null;
            }
        }
01010100b commented 3 years ago

Also, this code might not work, as I think EnumerateFiles doesn't return directories, EnumerateDirectories does that. You should set up a development environment so you can properly test things though.

db48x commented 3 years ago

I installed Visual Studio last night, but it fails to open the solution file. Perhaps it's because I installed VS2017? Apparently VS2019 isn't an option because I'm running it inside a virtual machine…

db48x commented 3 years ago

Clearly I need to find some way to detect errors locally.

01010100b commented 3 years ago

The solution requires the latest VS2019 indeed. There should be instructions in the description of one of the repos.