File indexing completed on 2024-05-12 04:51:06
0001 /* 0002 SPDX-FileCopyrightText: 1998-2010 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "k3bisooptions.h" 0007 #include "k3bcore.h" 0008 #include "k3bversion.h" 0009 #include "k3bglobals.h" 0010 #include "k3b_i18n.h" 0011 0012 #include <KConfig> 0013 #include <KConfigGroup> 0014 #include <QString> 0015 0016 0017 K3b::IsoOptions::IsoOptions() 0018 : m_defaultVolumeIDSet(false), 0019 m_volumeIDSet(false), 0020 m_applicationID( QString("K3B THE CD KREATOR (C) 1998-2018 SEBASTIAN TRUEG, MICHAL MALEK AND LESLIE ZHAI") ), 0021 m_systemId( K3b::systemName().toUpper() ), 0022 m_whiteSpaceTreatmentReplaceString( "_" ) 0023 { 0024 m_createRockRidge = true; 0025 m_createJoliet = true; 0026 m_createUdf = false; 0027 m_ISOallowLowercase = false; 0028 m_ISOallowPeriodAtBegin = false; 0029 m_ISOallow31charFilenames = true; 0030 m_ISOomitVersionNumbers = false; 0031 m_ISOomitTrailingPeriod = false; 0032 m_ISOmaxFilenameLength = false; 0033 m_ISOrelaxedFilenames = false; 0034 m_ISOnoIsoTranslate = false; 0035 m_ISOallowMultiDot = false; 0036 m_ISOuntranslatedFilenames = false; 0037 m_followSymbolicLinks = false; 0038 m_createTRANS_TBL = false; 0039 m_hideTRANS_TBL = false; 0040 m_jolietLong = true; 0041 0042 m_doNotCacheInodes = true; 0043 m_doNotImportSession = false; 0044 0045 m_isoLevel = 3; 0046 0047 m_discardSymlinks = false; 0048 m_discardBrokenSymlinks = false; 0049 0050 m_preserveFilePermissions = false; 0051 0052 m_whiteSpaceTreatment = noChange; 0053 0054 m_volumeSetSize = 1; 0055 m_volumeSetNumber = 1; 0056 } 0057 0058 0059 const QString& K3b::IsoOptions::volumeID() const { 0060 if (m_volumeIDSet) 0061 return m_volumeID; 0062 else { 0063 if (!m_defaultVolumeIDSet) { 0064 m_defaultVolumeIDSet = true; 0065 m_defaultVolumeID = i18nc( "This is the default volume identifier of a data project created by K3b. " 0066 "The string should not be longer than 16 characters to avoid warnings regarding " 0067 "Joiliet extensions which induce this restriction.", 0068 "K3b data project" ); 0069 } 0070 return m_defaultVolumeID; 0071 } 0072 } 0073 0074 0075 void K3b::IsoOptions::save( KConfigGroup c, bool saveVolumeDesc ) 0076 { 0077 if( saveVolumeDesc ) { 0078 c.writeEntry( "volume id", volumeID() ); 0079 c.writeEntry( "application id", m_applicationID ); 0080 c.writeEntry( "preparer", m_preparer ); 0081 c.writeEntry( "publisher", m_publisher ); 0082 c.writeEntry( "system id", m_systemId ); 0083 c.writeEntry( "volume set id", m_volumeSetId ); 0084 c.writeEntry( "volume set size", m_volumeSetSize ); 0085 c.writeEntry( "volume set number", m_volumeSetNumber ); 0086 c.writeEntry( "abstract file", m_abstractFile ); 0087 c.writeEntry( "copyright file", m_copyrightFile ); 0088 c.writeEntry( "bibliograph file", m_bibliographFile ); 0089 } 0090 0091 c.writeEntry( "rock_ridge", m_createRockRidge ); 0092 c.writeEntry( "joliet", m_createJoliet ); 0093 c.writeEntry( "udf", m_createUdf ); 0094 0095 // save iso-level 0096 c.writeEntry( "iso_level", m_isoLevel ); 0097 0098 c.writeEntry( "create TRANS_TBL", m_createTRANS_TBL ); 0099 c.writeEntry( "hide TRANS_TBL", m_hideTRANS_TBL ); 0100 c.writeEntry( "untranslated filenames", m_ISOuntranslatedFilenames ); 0101 c.writeEntry( "allow 31 character filenames", m_ISOallow31charFilenames ); 0102 c.writeEntry( "max ISO filenames", m_ISOmaxFilenameLength ); 0103 c.writeEntry( "allow beginning period", m_ISOallowPeriodAtBegin ); 0104 c.writeEntry( "relaxed filenames", m_ISOrelaxedFilenames ); 0105 c.writeEntry( "omit version numbers", m_ISOomitVersionNumbers ); 0106 c.writeEntry( "omit trailing period", m_ISOomitTrailingPeriod ); 0107 c.writeEntry( "no iSO translation", m_ISOnoIsoTranslate ); 0108 c.writeEntry( "allow multiple dots", m_ISOallowMultiDot ); 0109 c.writeEntry( "allow lowercase filenames", m_ISOallowLowercase ); 0110 c.writeEntry( "follow symbolic links", m_followSymbolicLinks ); 0111 0112 c.writeEntry( "joliet long", m_jolietLong ); 0113 0114 c.writeEntry( "do not cache inodes", m_doNotCacheInodes ); 0115 c.writeEntry( "do not import last session", m_doNotImportSession ); 0116 0117 // save whitespace-treatment 0118 switch( m_whiteSpaceTreatment ) { 0119 case strip: 0120 c.writeEntry( "white_space_treatment", "strip" ); 0121 break; 0122 case extended: 0123 c.writeEntry( "white_space_treatment", "extended" ); 0124 break; 0125 case replace: 0126 c.writeEntry( "white_space_treatment", "replace" ); 0127 break; 0128 default: 0129 c.writeEntry( "white_space_treatment", "noChange" ); 0130 } 0131 0132 c.writeEntry( "whitespace replace string", m_whiteSpaceTreatmentReplaceString ); 0133 0134 c.writeEntry( "discard symlinks", discardSymlinks() ); 0135 c.writeEntry( "discard broken symlinks", discardBrokenSymlinks() ); 0136 0137 c.writeEntry( "preserve file permissions", m_preserveFilePermissions ); 0138 } 0139 0140 0141 K3b::IsoOptions K3b::IsoOptions::load( const KConfigGroup& c, bool loadVolumeDesc ) 0142 { 0143 K3b::IsoOptions options; 0144 0145 if( loadVolumeDesc ) { 0146 options.setVolumeID( c.readEntry( "volume id", options.volumeID() ) ); 0147 options.setApplicationID( c.readEntry( "application id", options.applicationID() ) ); 0148 options.setPreparer( c.readEntry( "preparer", options.preparer() ) ); 0149 options.setPublisher( c.readEntry( "publisher", options.publisher() ) ); 0150 options.setSystemId( c.readEntry( "system id", options.systemId() ) ); 0151 options.setVolumeSetId( c.readEntry( "volume set id", options.volumeSetId() ) ); 0152 options.setVolumeSetSize( c.readEntry( "volume set size", options.volumeSetSize() ) ); 0153 options.setVolumeSetNumber( c.readEntry( "volume set number", options.volumeSetNumber() ) ); 0154 options.setAbstractFile( c.readEntry( "abstract file", options.abstractFile() ) ); 0155 options.setCoprightFile( c.readEntry( "copyright file", options.copyrightFile() ) ); 0156 options.setBibliographFile( c.readEntry( "bibliograph file", options.bibliographFile() ) ); 0157 } 0158 0159 options.setCreateRockRidge( c.readEntry( "rock_ridge", options.createRockRidge() ) ); 0160 options.setCreateJoliet( c.readEntry( "joliet", options.createJoliet() ) ); 0161 options.setCreateUdf( c.readEntry( "udf", options.createUdf() ) ); 0162 0163 options.setISOLevel( c.readEntry( "iso_level", options.ISOLevel() ) ); 0164 0165 options.setCreateTRANS_TBL( c.readEntry( "create TRANS_TBL", options.createTRANS_TBL() ) ); 0166 options.setHideTRANS_TBL( c.readEntry( "hide TRANS_TBL", options.hideTRANS_TBL() ) ); 0167 0168 // 0169 // We need to use the member variables here instead of the access methods 0170 // which do not return the actual value of the member variables but the value 0171 // representing the use in mkisofs (i.e. ISOomitVersionNumbers is also enabled 0172 // if ISOmaxFilenameLength is enabled. 0173 // 0174 options.setISOuntranslatedFilenames( c.readEntry( "untranslated filenames", options.m_ISOuntranslatedFilenames ) ); 0175 options.setISOallow31charFilenames( c.readEntry( "allow 31 character filenames", options.m_ISOallow31charFilenames ) ); 0176 options.setISOmaxFilenameLength( c.readEntry( "max ISO filenames", options.m_ISOmaxFilenameLength ) ); 0177 options.setISOallowPeriodAtBegin( c.readEntry( "allow beginning period", options.m_ISOallowPeriodAtBegin ) ); 0178 options.setISOrelaxedFilenames( c.readEntry( "relaxed filenames", options.m_ISOrelaxedFilenames ) ); 0179 options.setISOomitVersionNumbers( c.readEntry( "omit version numbers", options.m_ISOomitVersionNumbers ) ); 0180 options.setISOnoIsoTranslate( c.readEntry( "no iSO translation", options.m_ISOnoIsoTranslate ) ); 0181 options.setISOallowMultiDot( c.readEntry( "allow multiple dots", options.m_ISOallowMultiDot ) ); 0182 options.setISOallowLowercase( c.readEntry( "allow lowercase filenames", options.m_ISOallowLowercase ) ); 0183 options.setISOomitTrailingPeriod( c.readEntry( "omit trailing period", options.m_ISOomitTrailingPeriod ) ); 0184 0185 options.setFollowSymbolicLinks( c.readEntry( "follow symbolic links", options.m_followSymbolicLinks ) ); 0186 0187 options.setJolietLong( c.readEntry( "joliet long", options.jolietLong() ) ); 0188 0189 options.setDoNotCacheInodes( c.readEntry( "do not cache inodes", options.doNotCacheInodes() ) ); 0190 options.setDoNotImportSession( c.readEntry( "no not import last session", options.doNotImportSession() ) ); 0191 0192 QString w = c.readEntry( "white_space_treatment", "noChange" ); 0193 if( w == "replace" ) 0194 options.setWhiteSpaceTreatment( replace ); 0195 else if( w == "strip" ) 0196 options.setWhiteSpaceTreatment( strip ); 0197 else if( w == "extended" ) 0198 options.setWhiteSpaceTreatment( extended ); 0199 else 0200 options.setWhiteSpaceTreatment( noChange ); 0201 0202 options.setWhiteSpaceTreatmentReplaceString( c.readEntry( "whitespace replace string", options.whiteSpaceTreatmentReplaceString() ) ); 0203 0204 options.setDiscardSymlinks( c.readEntry("discard symlinks", options.discardSymlinks() ) ); 0205 options.setDiscardBrokenSymlinks( c.readEntry("discard broken symlinks", options.discardBrokenSymlinks() ) ); 0206 0207 options.setPreserveFilePermissions( c.readEntry( "preserve file permissions", options.preserveFilePermissions() ) ); 0208 0209 return options; 0210 } 0211 0212 0213 K3b::IsoOptions K3b::IsoOptions::defaults() 0214 { 0215 // let the constructor create defaults 0216 return K3b::IsoOptions(); 0217 }