/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void handleCommand(
std::string_view rInPath, std::string_view rOutPath, const std::string& rExecutable)
{
OStringBuffer buf; if (rExecutable == "uiex" || rExecutable == "hrcex")
{ #if !defined _WIN32 // For now, this is only needed by some Linux ASan builds, so keep it simply and disable it // on Windows (which doesn't support the relevant shell syntax for (un-)setting environment // variables). autoconst n = libraryPathEnvVarOverride.indexOf('='); if (n == -1) {
buf.append("unset -v " + libraryPathEnvVarOverride + " && ");
} else {
buf.append(libraryPathEnvVarOverride + " ");
} #endif autoconst env = getenv("SRC_ROOT");
assert(env != nullptr);
buf.append(OString::Concat(env) + "/solenv/bin/");
} else
{ #ifdefined MACOSX if (autoconst env = getenv("DYLD_LIBRARY_PATH")) {
buf.append(OString::Concat("DYLD_LIBRARY_PATH=") + env + " ");
} #endif autoconst env = getenv("WORKDIR_FOR_BUILD");
assert(env != nullptr);
buf.append(OString::Concat(env) + "/LinkTarget/Executable/");
}
buf.append(OString::Concat(std::string_view(rExecutable))
+ " -i " + rInPath + " -o " + rOutPath);
if (system(buf.getStr()) != 0)
{
std::cerr << "Error: Failed to execute " << buf.getStr() << '\n'; throwfalse; //TODO
}
}
void InitPoFile(
std::string_view rProject, std::string_view rInPath,
std::string_view rPotDir, const OString& rOutPath )
{ //Create directory for po file
{
OUString outDir =
OStringToOUString(
rPotDir.substr(0,rPotDir.rfind('/')), RTL_TEXTENCODING_UTF8);
OUString outDirUrl; if (osl::FileBase::getFileURLFromSystemPath(outDir, outDirUrl)
!= osl::FileBase::E_None)
{
std::cerr
<< ("Error: Cannot convert pathname to URL in " __FILE__ ", in line ")
<< __LINE__ << "\n outDir: "
<< outDir
<< "\n"; throwfalse; //TODO
}
osl::Directory::createPath(outDirUrl);
}
//Add header to the po file
PoOfstream aPoOutPut;
aPoOutPut.open(rOutPath); if (!aPoOutPut.isOpen())
{
std::cerr
<< "Error: Cannot open po file "
<< rOutPath << "\n"; throwfalse; //TODO
}
{ //Delete pot file if it contain only the header
PoIfstream aPOStream(sOutPath);
PoEntry aPO;
aPOStream.readEntry( aPO ); bool bDel = aPOStream.eof();
aPOStream.close();
if (bDel)
{ if ( system(OString("rm " + sOutPath).getStr()) != 0 )
{
std::cerr
<< "Error: Cannot remove entryless pot file: "
<< sOutPath << "\n"; throwfalse; //TODO
}
} elseif (bCreatedFile && bSimpleModuleCase)
{ // add one stock Add, Cancel, Close, Help, No, OK, Yes entry to each module.po // and duplicates in .ui files then filtered out by solenv/bin/uiex
/// Handle one directory in the hierarchy. /// /// Ignores symlinks and instead explicitly descends into clone/* or src/*, /// as the Cygwin symlinks are not supported by osl::Directory on Windows. /// /// @param rUrl the absolute file URL of this directory /// /// @param nLevel 0 if this is the root directory (core repository) /// that contains the individual modules. 1 if it is a toplevel module and /// larger values for the subdirectories. /// /// @param rProject the name of the project (empty and ignored if nLevel <= 0) /// @param rPotDir the path of pot directory void handleDirectory( const OUString& rUrl, int nLevel, const OString& rProject, const OString& rPotDir)
{
osl::Directory dir(rUrl); if (dir.open() != osl::FileBase::E_None) {
std::cerr
<< "Error: Cannot open directory: " << rUrl << '\n'; throwfalse; //TODO
}
std::vector<OUString> aFileNames;
std::map<OUString, std::map<OString, OString>> aSubDirs; for (;;) {
osl::DirectoryItem item;
osl::FileBase::RC e = dir.getNextItem(item); if (e == osl::FileBase::E_NOENT) { break;
} if (e != osl::FileBase::E_None) {
std::cerr << "Error: Cannot read directory\n"; throwfalse; //TODO
}
osl::FileStatus stat(
osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName
| osl_FileStatus_Mask_FileURL); if (item.getFileStatus(stat) != osl::FileBase::E_None) {
std::cerr << "Error: Cannot get file status\n"; throwfalse; //TODO
} const OString sDirName =
OUStringToOString(stat.getFileName(),RTL_TEXTENCODING_UTF8); switch (nLevel)
{ case 0: // a root directory if (stat.getFileType() == osl::FileStatus::Directory && includeProject(sDirName))
aSubDirs[stat.getFileURL()][sDirName] = rPotDir + "/" + sDirName; break; default: if (stat.getFileType() == osl::FileStatus::Directory)
aSubDirs[stat.getFileURL()][rProject] = rPotDir + "/" + sDirName; else
aFileNames.push_back(stat.getFileURL()); break;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.