SEToolbox.Models.SelectWorldModel.FindSaveSession C# (CSharp) Method

FindSaveSession() static private method

static private FindSaveSession ( string baseSavePath, string findSession ) : WorldResource
baseSavePath string
findSession string
return WorldResource
        internal static WorldResource FindSaveSession(string baseSavePath, string findSession)
        {
            if (Directory.Exists(baseSavePath))
            {
                var userPaths = Directory.GetDirectories(baseSavePath);

                foreach (var userPath in userPaths)
                {
                    var lastLoadedFile = Path.Combine(userPath, SpaceEngineersConsts.LoadLoadedFilename);

                    // Ignore any other base Save paths without the LastLoaded file.
                    if (File.Exists(lastLoadedFile))
                    {
                        var savePaths = Directory.GetDirectories(userPath);

                        // Still check every potential game world path.
                        foreach (var savePath in savePaths)
                        {
                            var saveResource = new WorldResource
                            {
                                Savename = Path.GetFileName(savePath),
                                UserName = Path.GetFileName(userPath),
                                Savepath = savePath,
                                DataPath = UserDataPath.FindFromSavePath(savePath)
                            };

                            saveResource.LoadCheckpoint();

                            if (saveResource.Savename.ToUpper() == findSession || saveResource.SessionName.ToUpper() == findSession)
                            {
                                return saveResource;
                            }
                        }
                    }
                }
            }

            return null;
        }