예제 #1
0
        public static IEnumerable <UserProfile> IterateAllUserProfiles()
        {
            string profileDirectory = IOUtilities.CombinePath(PluginSettings.CACHE_DIRECTORY,
                                                              "users");

            if (LocalDataStorage.GetDirectoryExists(profileDirectory))
            {
                IList <string> userFiles;
                try
                {
                    userFiles = LocalDataStorage.GetFiles(profileDirectory, null, false);
                }
                catch (Exception e)
                {
                    string warningInfo = ("[mod.io] Failed to read user profile directory."
                                          + "\nDirectory: " + profileDirectory + "\n\n");

                    Debug.LogWarning(warningInfo
                                     + Utility.GenerateExceptionDebugString(e));

                    userFiles = new string[0];
                }

                foreach (string profileFilePath in userFiles)
                {
                    UserProfile profile;
                    LocalDataStorage.ReadJSONFile(profileFilePath, out profile);

                    if (profile != null)
                    {
                        yield return(profile);
                    }
                }
            }
        }