Annotation of truecrypt/main/favoritevolume.cpp, revision 1.1.1.1

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
                      4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
                      5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #include "System.h"
                     10: #include "Application.h"
                     11: #include "FavoriteVolume.h"
                     12: #include "GraphicUserInterface.h"
                     13: #include "Xml.h"
                     14: 
                     15: namespace TrueCrypt
                     16: {
                     17:        FavoriteVolumeList FavoriteVolume::LoadList ()
                     18:        {
                     19:                FavoriteVolumeList favorites;
                     20: 
                     21:                FilePath path = Application::GetConfigFilePath (GetFileName());
                     22: 
                     23:                if (path.IsFile())
                     24:                {
                     25:                        foreach (XmlNode node, XmlParser (path).GetNodes (L"volume"))
                     26:                        {
                     27:                                VolumeSlotNumber slotNumber = 0;
                     28:                                wstring slotAttr = wstring (node.Attributes[L"slotnumber"]);
                     29:                                if (!slotAttr.empty())
                     30:                                        slotNumber = StringConverter::ToUInt64 (slotAttr);
                     31:                                
                     32:                                favorites.push_back (shared_ptr <FavoriteVolume> (
                     33:                                        new FavoriteVolume ((wstring) node.InnerText, wstring (node.Attributes[L"mountpoint"]), slotNumber)));
                     34:                        }
                     35:                }
                     36: 
                     37:                return favorites;
                     38:        }
                     39: 
                     40:        void FavoriteVolume::SaveList (const FavoriteVolumeList &favorites)
                     41:        {
                     42:                FilePath favoritesCfgPath = Application::GetConfigFilePath (GetFileName(), true);
                     43: 
                     44:                if (favorites.empty())
                     45:                {
                     46:                        if (favoritesCfgPath.IsFile())
                     47:                                favoritesCfgPath.Delete();
                     48:                }
                     49:                else
                     50:                {
                     51:                        XmlNode favoritesXml (L"favorites");
                     52: 
                     53:                        foreach_ref (const FavoriteVolume &favorite, favorites)
                     54:                        {
                     55:                                XmlNode node (L"volume", wstring (favorite.Path));
                     56:                                node.Attributes[L"mountpoint"] = wstring (favorite.MountPoint);
                     57:                                node.Attributes[L"slotnumber"] = StringConverter::FromNumber (favorite.SlotNumber);
                     58: 
                     59:                                favoritesXml.InnerNodes.push_back (node);
                     60:                        }
                     61: 
                     62:                        XmlWriter favoritesWriter (favoritesCfgPath);
                     63:                        favoritesWriter.WriteNode (favoritesXml);
                     64:                        favoritesWriter.Close();
                     65:                }
                     66:        }
                     67: 
                     68:        void FavoriteVolume::ToMountOptions (MountOptions &options) const
                     69:        {
                     70:                if (MountPoint.IsEmpty())
                     71:                {
                     72:                        options.MountPoint.reset();
                     73:                        options.NoFilesystem = true;
                     74:                }
                     75:                else
                     76:                        options.MountPoint.reset (new DirectoryPath (MountPoint));
                     77: 
                     78:                options.Path.reset (new VolumePath (Path));
                     79:                options.SlotNumber = SlotNumber;
                     80:        }
                     81: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.