@cond Doxygen_Suppress
| 1980 | |
| 1981 | //! @cond Doxygen_Suppress |
| 1982 | CPLErr GDALDriver::DefaultCopyFiles(const char *pszNewName, |
| 1983 | const char *pszOldName) |
| 1984 | |
| 1985 | { |
| 1986 | /* -------------------------------------------------------------------- */ |
| 1987 | /* Collect file list. */ |
| 1988 | /* -------------------------------------------------------------------- */ |
| 1989 | auto poDS = std::unique_ptr<GDALDataset>( |
| 1990 | GDALDataset::Open(pszOldName, GDAL_OF_ALL | GDAL_OF_VERBOSE_ERROR, |
| 1991 | nullptr, nullptr, nullptr)); |
| 1992 | |
| 1993 | if (!poDS) |
| 1994 | { |
| 1995 | if (CPLGetLastErrorNo() == 0) |
| 1996 | CPLError(CE_Failure, CPLE_OpenFailed, |
| 1997 | "Unable to open %s to obtain file list.", pszOldName); |
| 1998 | |
| 1999 | return CE_Failure; |
| 2000 | } |
| 2001 | |
| 2002 | const CPLStringList aosFileList(poDS->GetFileList()); |
| 2003 | |
| 2004 | poDS.reset(); |
| 2005 | |
| 2006 | if (aosFileList.empty()) |
| 2007 | { |
| 2008 | CPLError(CE_Failure, CPLE_NotSupported, |
| 2009 | "Unable to determine files associated with %s,\n" |
| 2010 | "copy fails.", |
| 2011 | pszOldName); |
| 2012 | |
| 2013 | return CE_Failure; |
| 2014 | } |
| 2015 | |
| 2016 | /* -------------------------------------------------------------------- */ |
| 2017 | /* Produce a list of new filenames that correspond to the old */ |
| 2018 | /* names. */ |
| 2019 | /* -------------------------------------------------------------------- */ |
| 2020 | CPLErr eErr = CE_None; |
| 2021 | const CPLStringList aosNewFileList( |
| 2022 | CPLCorrespondingPaths(pszOldName, pszNewName, aosFileList.List())); |
| 2023 | |
| 2024 | if (aosNewFileList.empty()) |
| 2025 | return CE_Failure; |
| 2026 | |
| 2027 | // Guaranteed by CPLCorrespondingPaths() |
| 2028 | CPLAssert(aosNewFileList.size() == aosFileList.size()); |
| 2029 | |
| 2030 | VSIStatBufL sStatBuf; |
| 2031 | if (VSIStatL(pszOldName, &sStatBuf) == 0 && VSI_ISDIR(sStatBuf.st_mode) && |
| 2032 | VSIStatL(pszNewName, &sStatBuf) != 0) |
| 2033 | { |
| 2034 | if (VSIMkdirRecursive(pszNewName, 0755) != 0) |
| 2035 | { |
| 2036 | CPLError(CE_Failure, CPLE_AppDefined, |
| 2037 | "Cannot create directory '%s'", pszNewName); |
| 2038 | return CE_Failure; |
| 2039 | } |
nothing calls this directly
no test coverage detected