Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions SAMAPI/LibraryFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static class LibraryFoldersHelper
const string LIBRARY_FOLDERS_NAME = "libraryfolders.vdf"; //The default file name of the file which lists all the library folders of steam.
const string LIBFILE_NODE_NAME = "LibraryFolders"; //The node name inside the Library Folders file which contains the list of our steam libraries
const string APPMANIFEST_SEARCH_STRING = "appmanifest_*.acf"; //The search pattern to be used for searching steam apps manifest.

const string LIBRARYFOLDER_NODE_PATH_NAME = "path"; //The search pattern to be used for searching steam apps manifest.

/// <summary>
/// Lists all the library folders of the steam installation.
Expand All @@ -32,16 +32,35 @@ public static List<string> RetrieveLibraryFolders(string MainSteamInstallPath)

VDFNode vNode = vdfReader.Nodes.FindNode(LIBFILE_NODE_NAME); //Find the node that contains the list of steam libraries.

if (vNode == null || vNode.Keys == null || vNode.Keys.Count == 0) //If it isn't found or the Nodes key is null or empty, there's nothing else to be done. Return the list of libraryfolders that we already have. (which is just MainSteamInstallPath)
if (vNode == null) //If it isn't found or the Nodes key is null or empty, there's nothing else to be done. Return the list of libraryfolders that we already have. (which is just MainSteamInstallPath)
return libraryFolders;

foreach (VDFKey vKey in vNode.Keys) //List all the keys inside the vNode node.
if (vNode.Keys != null)
{
if (vKey.Name.IsInteger()) //As per what I've seen from the Library Folders file, it seems that the key name for the location of the folders itself is a number so check if the key name is a number.
foreach (VDFKey vKey in vNode.Keys) //List all the keys inside the vNode node.
{
libraryFolders.Add(vKey.Value);
if (vKey.Name.IsInteger()) //As per what I've seen from the Library Folders file, it seems that the key name for the location of the folders itself is a number so check if the key name is a number.
{
libraryFolders.Add(vKey.Value);
}
}
}

if (vNode.Nodes != null)
{
foreach (VDFNode node in vNode.Nodes) //List all the keys inside the vNode node.
{
if (node.Name.IsInteger()) //As per what I've seen from the Library Folders file, it seems that the key name for the location of the folders itself is a number so check if the key name is a number.
{
var pathKey = node.Keys.FindKey(LIBRARYFOLDER_NODE_PATH_NAME);
if (pathKey == null)
continue;

libraryFolders.Add(pathKey.Value);
}
}
}

return libraryFolders;
}

Expand Down
10 changes: 4 additions & 6 deletions SAMAPI/SteamApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SteamApp

/// <summary>
/// The name of the Steam application.
/// This name may be empty for old/legacy packages, such as old installs of Source 2007 Dedicated Server.
/// </summary>
public string Name { get { return _Name; } }
/// <summary>
Expand Down Expand Up @@ -124,12 +125,10 @@ void init (VDFData vdfdata, string LibPath)
if (vNode.Keys == null || vNode.Keys.Count == 0)
throw new NullReferenceException("Node " + MANIFEST_NODE + " list of keys is either null or empty!");

VDFKey vKey = vNode.Keys.FindKey(MANIFEST_KEY_NAME); //Locate our first key which will be the name of the app.
VDFKey vKey;

if (vKey != null)
_Name = vKey.Value;
else
throw new NullReferenceException("Key pertaining to the name of the app is not found under " + MANIFEST_NODE + " node.");
// Not all applications have a name; please note applications such as "Source 2007 Dedicated Server" (ID: 310)
_Name = vNode.Keys.FindKey(MANIFEST_KEY_NAME)?.Value;

vKey = vNode.Keys.FindKey(MANIFEST_KEY_APPID);

Expand All @@ -156,7 +155,6 @@ void init (VDFData vdfdata, string LibPath)
}
else
throw new NullReferenceException("Key pertaining to the directory name containing the app under " + MANIFEST_NODE + " node is not found!");

}

/// <summary>
Expand Down