VirtualBox

Changeset 75418 in vbox


Ignore:
Timestamp:
Nov 13, 2018 12:09:09 PM (6 years ago)
Author:
vboxsync
Message:

Recording/Main: Made the IRecordingScreenSettings::fileName getters and setters a bit more convenient by automatically returning the VM's default recording file name if no value or a simple dot ('.') is set.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/RecordingSettingsImpl.h

    r75361 r75418  
    5656    void i_applyDefaults(void);
    5757
    58     int i_getDefaultFileName(Utf8Str &strFile);
     58    int i_getDefaultFileName(Utf8Str &strFile, bool fWithFileExtension);
    5959    bool i_canChangeSettings(void);
    6060    void i_onSettingsChanged(void);
  • trunk/src/VBox/Main/src-server/RecordingScreenSettingsImpl.cpp

    r75366 r75418  
    371371    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    372372
    373     aFileName = m->bd->File.strName;
    374 
    375     return S_OK;
    376 }
    377 
    378 HRESULT RecordingScreenSettings::setFileName(const com::Utf8Str &aFileName)
    379 {
    380     AutoCaller autoCaller(this);
    381     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    382 
    383     if (!m->pParent->i_canChangeSettings())
    384         return setError(E_INVALIDARG, tr("Cannot change file name while recording is enabled"));
    385 
    386     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    387 
    388     /* Get default file name if an empty string or a single "." is passed. */
    389     Utf8Str strFile(aFileName);
    390     if (   strFile.isEmpty()
    391         || strFile.equals("."))
    392     {
    393         int vrc = m->pParent->i_getDefaultFileName(strFile);
     373    /* Get default file name if an empty string or a single "." is set. */
     374    if (   m->bd->File.strName.isEmpty()
     375        || m->bd->File.strName.equals("."))
     376    {
     377        int vrc = m->pParent->i_getDefaultFileName(m->bd->File.strName, true /* fWithFileExtension */);
    394378        if (RT_FAILURE(vrc))
    395379            return setError(E_INVALIDARG, tr("Error retrieving default file name"));
    396380    }
    397381
     382    aFileName = m->bd->File.strName;
     383
     384    return S_OK;
     385}
     386
     387HRESULT RecordingScreenSettings::setFileName(const com::Utf8Str &aFileName)
     388{
     389    AutoCaller autoCaller(this);
     390    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     391
     392    if (!m->pParent->i_canChangeSettings())
     393        return setError(E_INVALIDARG, tr("Cannot change file name while recording is enabled"));
     394
     395    Utf8Str strFile(aFileName);
    398396    if (!RTPathStartsWithRoot(strFile.c_str()))
    399397        return setError(E_INVALIDARG, tr("Recording file name '%s' is not absolute"), strFile.c_str());
     398
     399    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    400400
    401401    m->bd.backup();
     
    817817        {
    818818            if (m->bd->File.strName.isEmpty())
    819                 rc = m->pParent->i_getDefaultFileName(m->bd->File.strName);
     819                rc = m->pParent->i_getDefaultFileName(m->bd->File.strName, true /* fWithExtension */);
    820820            break;
    821821        }
  • trunk/src/VBox/Main/src-server/RecordingSettingsImpl.cpp

    r75367 r75418  
    566566 * Returns the full path to the default video capture file.
    567567 */
    568 int RecordingSettings::i_getDefaultFileName(Utf8Str &strFile)
     568int RecordingSettings::i_getDefaultFileName(Utf8Str &strFile, bool fWithFileExtension)
    569569{
    570570    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    572572    strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox
    573573    strFile.stripSuffix();                          // path/to/machinesfolder/vmname/vmname
    574     strFile.append(".webm");                        // path/to/machinesfolder/vmname/vmname.webm
     574    if (fWithFileExtension)
     575        strFile.append(".webm");                    // path/to/machinesfolder/vmname/vmname.webm
    575576
    576577    return VINF_SUCCESS;
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