VirtualBox

Changeset 28692 in vbox


Ignore:
Timestamp:
Apr 24, 2010 7:14:03 PM (15 years ago)
Author:
vboxsync
Message:

iprt: XmlFileWrite - expose the two suffixes write() uses when fSafe is set.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/xml.h

    r28689 r28692  
    683683     *                                 specified name.
    684684     *                              -# The directory changes are flushed to disk.
     685     *                          The suffixes are available via s_pszTmpSuff and
     686     *                          s_pszPrevSuff.
    685687     */
    686688    void write(const char *pcszFilename, bool fSafe);
    687689
    688690    static int WriteCallback(void *aCtxt, const char *aBuf, int aLen);
    689     static int CloseCallback (void *aCtxt);
     691    static int CloseCallback(void *aCtxt);
     692
     693    /** The suffix used by XmlFileWriter::write() for the temporary file. */
     694    static const char * const s_pszTmpSuff;
     695    /** The suffix used by XmlFileWriter::write() for the previous (backup) file. */
     696    static const char * const s_pszPrevSuff;
    690697
    691698private:
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r28689 r28692  
    15341534        /* Construct both filenames first to ease error handling.  */
    15351535        char szTmpFilename[RTPATH_MAX];
    1536         int rc = RTStrCopy(szTmpFilename, sizeof(szTmpFilename) - sizeof("-tmp") + 1, pcszFilename);
     1536        int rc = RTStrCopy(szTmpFilename, sizeof(szTmpFilename) - strlen(s_pszTmpSuff), pcszFilename);
    15371537        if (RT_FAILURE(rc))
    15381538            throw EIPRTFailure(rc, "RTStrCopy");
    1539         strcat(szTmpFilename, "-tmp");
     1539        strcat(szTmpFilename, s_pszTmpSuff);
    15401540
    15411541        char szPrevFilename[RTPATH_MAX];
    1542         rc = RTStrCopy(szPrevFilename, sizeof(szPrevFilename) - sizeof("-prev") + 1, pcszFilename);
     1542        rc = RTStrCopy(szPrevFilename, sizeof(szPrevFilename) - strlen(s_pszPrevSuff), pcszFilename);
    15431543        if (RT_FAILURE(rc))
    15441544            throw EIPRTFailure(rc, "RTStrCopy");
    1545         strcat(szPrevFilename, "-prev");
     1545        strcat(szPrevFilename, s_pszPrevSuff);
    15461546
    15471547        /* Write the XML document to the temporary file.  */
     
    15911591}
    15921592
     1593/*static*/ const char * const XmlFileWriter::s_pszTmpSuff  = "-tmp";
     1594/*static*/ const char * const XmlFileWriter::s_pszPrevSuff = "-prev";
     1595
    15931596
    15941597} // end namespace xml
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette