コード例 #1
0
ファイル: java_lang_Class.c プロジェクト: Custard7/robovm
Class* Java_java_lang_Class_classForName(Env* env, Class* cls, Object* className, jboolean initializeBoolean,
            ClassLoader* classLoader) {

    if (!className) {
        rvmThrowNullPointerException(env);
        return NULL;
    }
    char* classNameUTF = toBinaryName(env, className);
    if (!classNameUTF) return NULL;
    Class* clazz = rvmFindClassUsingLoader(env, classNameUTF, classLoader);
    if (!clazz) {
        // FIXME: Temp fix to prevent warnings from the ObjC bridge about missing XXX$Callbacks classes
        if (!endsWith(classNameUTF, "$Callbacks")) {
            char* p = classNameUTF;
            while (*p != '\0') {
                if (*p == '/') *p = '.';
                p++;
            }
            WARNF("Class.forName() failed to load '%s'. "
                  "Use the -forcelinkclasses command line option "
                  "or add <forceLinkClasses><pattern>%s</pattern></forceLinkClasses> "
                  "to your robovm.xml file to link it in.",
                  classNameUTF, classNameUTF);
        }
        return NULL;
    }
    if (initializeBoolean) {
        rvmInitialize(env, clazz);
        if (rvmExceptionCheck(env)) return NULL;
    }
    return clazz;
}
コード例 #2
0
ファイル: engine.cpp プロジェクト: meganyao/mongo
    bool Scope::execFile( const string& filename , bool printResult , bool reportError , bool assertOnError, int timeoutMs ){
        
        path p( filename );

        if ( ! exists( p ) ){
            log() << "file [" << filename << "] doesn't exist" << endl;
            if ( assertOnError )
                assert( 0 );
            return false;
        }

        // iterate directories and recurse using all *.js files in the directory
        if ( is_directory( p ) ){
            directory_iterator end;
            bool empty = true;
            for (directory_iterator it (p); it != end; it++){
                empty = false;
                path sub (*it);
                if (!endsWith(sub.string().c_str(), ".js"))
                    continue;
                if (!execFile(sub.string().c_str(), printResult, reportError, assertOnError, timeoutMs))
                    return false;
            }

            if (empty){
                log() << "directory [" << filename << "] doesn't have any *.js files" << endl;
                if ( assertOnError )
                    assert( 0 );
                return false;
            }

            return true;
        }
        
        File f;
        f.open( filename.c_str() , true );

        unsigned L;
        {
            fileofs fo = f.len();
            assert( fo <= 0x7ffffffe );
            L = (unsigned) fo;
        }
        boost::scoped_array<char> data (new char[L+1]);
        data[L] = 0;
        f.read( 0 , data.get() , L );

        int offset = 0;
        if (data[0] == '#' && data[1] == '!'){
            const char* newline = strchr(data.get(), '\n');
            if (! newline)
                return true; // file of just shebang treated same as empty file
            offset = newline - data.get();
        }

        StringData code (data.get() + offset, L - offset);
        
        return exec( code , filename , printResult , reportError , assertOnError, timeoutMs );
    }
コード例 #3
0
ファイル: ogr_file_format.cpp プロジェクト: 999999333/mapper
Object* OgrFileImport::importPointGeometry(MapPart* map_part, OGRFeatureH feature, OGRGeometryH geometry)
{
	auto style = OGR_F_GetStyleString(feature);
	auto symbol = getSymbol(Symbol::Point, style);
	if (symbol->getType() == Symbol::Point)
	{
		auto object = new PointObject(symbol);
		object->setPosition(toMapCoord(OGR_G_GetX(geometry, 0), OGR_G_GetY(geometry, 0)));
		map_part->addObject(object);
		return object;
	}
	else if (symbol->getType() == Symbol::Text)
	{
		const auto& description = symbol->getDescription();
		auto length = description.length();
		auto split = description.indexOf(QLatin1Char(' '));
		Q_ASSERT(split > 0);
		Q_ASSERT(split < length);
		
		auto label = description.right(length - split - 1);
		if (label.startsWith('{') && label.endsWith('}'))
		{
			label.remove(0,1);
			label.chop(1);
			int index = OGR_F_GetFieldIndex(feature, label.toLatin1());
			if (index >= 0)
			{
				label = QString(OGR_F_GetFieldAsString(feature, index));
			}
		}
		if (!label.isEmpty())
		{
			auto object = new TextObject(symbol);
			object->setAnchorPosition(toMapCoord(OGR_G_GetX(geometry, 0), OGR_G_GetY(geometry, 0)));
			// DXF observation
			label.replace(QRegularExpression("(\\\\[^;]*;)*", QRegularExpression::MultilineOption), QString::null);
			label.replace(QLatin1String("^I"), "\t");
			object->setText(label);
			
			bool ok;
			auto anchor = QStringRef(&description, 1, 2).toInt(&ok);
			if (ok)
			{
				applyLabelAnchor(anchor, object);
			}
				
			auto angle = QStringRef(&description, 3, split-3).toFloat(&ok);
			if (ok)
			{
				object->setRotation(qDegreesToRadians(angle));
			}
			
			map_part->addObject(object);
			return object;
		}
	}
	
	return nullptr;
}
コード例 #4
0
ファイル: mcff2mcf.c プロジェクト: binoc-software/mozilla-cvs
void
derelativizeURL (char* tok, char* url, RDFFile f)
{
  if ((tok[0] == '/') && (endsWith(".mco", tok))) {
	void stringAppendBase (char* dest, const char* addition) ;
    stringAppendBase(url, f->url); 
    stringAppend(url, "#");
    stringAppend(url, tok);
  } else if  ((endsWith(".mco", tok)) && (charSearch('#', tok) == -1)) {
    void stringAppendBase (char* dest, const char* addition) ;
    stringAppendBase(url, f->url);
    stringAppend(url, "#");
    stringAppend(url, tok);
  } else {
    memcpy(url, tok, strlen(tok));
  }
}
コード例 #5
0
ファイル: bitstream.cpp プロジェクト: JohanssonDaniel/Huffman
/* Member function ofbitstream::open
 * -------------------------------------------
 * Attempts to open the specified file, failing if unable
 * to do so.
 */
void ofbitstream::open(const char* filename) {
    /* Confirm we aren't about to do something that could potentially be a
    * Very Bad Idea.
    */
    if (endsWith(filename, ".cpp") || endsWith(filename, ".h") ||
            endsWith(filename, ".hh") || endsWith(filename, ".cc")) {
        error(string("It is potentially dangerous to write to file ")
             + filename + ", because that might be your own source code.  "
             + "We are explicitly disallowing this operation.  Please choose a "
             + "different filename.");
        setstate(ios::failbit);
    } else {
        if (!fb.open(filename, ios::out | ios::binary)) {
            setstate(ios::failbit);
        }
    }
}
コード例 #6
0
ファイル: launcher.cpp プロジェクト: aykutalparslan/tdesktop
void Launcher::prepareSettings() {
#ifdef Q_OS_MAC
#ifndef OS_MAC_OLD
	if (QSysInfo::macVersion() >= QSysInfo::MV_10_11) {
		gIsElCapitan = true;
	}
#else // OS_MAC_OLD
	if (QSysInfo::macVersion() < QSysInfo::MV_10_7) {
		gIsSnowLeopard = true;
	}
#endif // OS_MAC_OLD
#endif // Q_OS_MAC

	switch (cPlatform()) {
	case dbipWindows:
#ifndef OS_WIN_STORE
		gPlatformString = qsl("Windows");
#else // OS_WIN_STORE
		gPlatformString = qsl("WinStore");
#endif // OS_WIN_STORE
	break;
	case dbipMac:
#ifndef OS_MAC_STORE
		gPlatformString = qsl("MacOS");
#else // OS_MAC_STORE
		gPlatformString = qsl("MacAppStore");
#endif // OS_MAC_STORE
	break;
	case dbipMacOld:
		gPlatformString = qsl("MacOSold");
	break;
	case dbipLinux64:
		gPlatformString = qsl("Linux64bit");
	break;
	case dbipLinux32:
		gPlatformString = qsl("Linux32bit");
	break;
	}

	auto path = Platform::CurrentExecutablePath(_argc, _argv);
	LOG(("Executable path before check: %1").arg(path));
	if (!path.isEmpty()) {
		auto info = QFileInfo(path);
		if (info.isSymLink()) {
			info = info.symLinkTarget();
		}
		if (info.exists()) {
			const auto dir = info.absoluteDir().absolutePath();
			gExeDir = (dir.endsWith('/') ? dir : (dir + '/'));
			gExeName = info.fileName();
		}
	}
	if (cExeName().isEmpty()) {
		LOG(("WARNING: Could not compute executable path, some features will be disabled."));
	}

	processArguments();
}
コード例 #7
0
ファイル: TestExecutor.cpp プロジェクト: ali-dar/VoloDB
void TestExecutor::handle(ConfigFileReader& testSettings)
{
    auto testCases = testSettings.getSettings();
    for(auto testCase: testCases)
    {
        shared_ptr<TestBase> currentTestCase;
        
        if(testCase.second.find("disabled") != testCase.second.end())
            continue;

        if(endsWith(testCase.first,"TransportTest"))
            currentTestCase.reset(new ClientTransportTest<BasicTransportTask<char*>>(testCase.first));
        else if(endsWith(testCase.first, "CreateStoreTest-AllTypes"))
            currentTestCase.reset(new CreateStoreTestAllTypes<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        else if(endsWith(testCase.first, "DropStoreTest-AllTypes"))
            currentTestCase.reset(new DropStoreTestAllTypes<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        else if(endsWith(testCase.first, "SetTest-Simple"))
            currentTestCase.reset(new SetTestSimple<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        else if(endsWith(testCase.first, "DeleteTest-Simple"))
            currentTestCase.reset(new DeleteTestSimple<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        else if(endsWith(testCase.first, "GetTest-Simple"))
            currentTestCase.reset(new GetTestSimple<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        else if(endsWith(testCase.first, "PruneIndexScan"))
            currentTestCase.reset(new PruneIndexScan<BasicTaskExecution<shared_ptr< ::google::protobuf::Message>>>(testCase.first));
        
        if(currentTestCase.get())
            currentTestCase->run(testCase.second);

    }
    
     FILE_LOG(logINFO)<<"Finished Tests";
}
コード例 #8
0
ファイル: pslPartition.c プロジェクト: Nicholas-NVS/kentUtils
static struct pipeline *openPslSortPipe(char *pslFile)
/* open pipeline that sorts psl */
{
    static char *zcatCmd[] = {"zcat", NULL};
    static char *bzcatCmd[] = {"zcat", NULL};
    static char *sortCmd[] = {"sort", "-k", "14,14", "-k", "16,16n", "-k", "17,17nr", NULL};
    int iCmd = 0;
    char **cmds[3];

    if (endsWith(pslFile, ".gz") || endsWith(pslFile, ".Z"))
        cmds[iCmd++] = zcatCmd;
    else if (endsWith(pslFile, ".bz2"))
        cmds[iCmd++] = bzcatCmd;
    cmds[iCmd++] = sortCmd;
    cmds[iCmd++] = NULL;

    return pipelineOpen(cmds, pipelineRead, pslFile, NULL);
}
コード例 #9
0
ファイル: engine.cpp プロジェクト: avish/mongo
    bool Scope::execFile(const string& filename, bool printResult, bool reportError,
                         int timeoutMs) {
#ifdef _WIN32
        boost::filesystem::path p(toWideString(filename.c_str()));
#else
        boost::filesystem::path p(filename);
#endif
        if (!exists(p)) {
            log() << "file [" << filename << "] doesn't exist" << endl;
            return false;
        }

        // iterate directories and recurse using all *.js files in the directory
        if (boost::filesystem::is_directory(p)) {
            boost::filesystem::directory_iterator end;
            bool empty = true;

            for (boost::filesystem::directory_iterator it (p); it != end; it++) {
                empty = false;
                boost::filesystem::path sub(*it);
                if (!endsWith(sub.string().c_str(), ".js"))
                    continue;
                if (!execFile(sub.string(), printResult, reportError, timeoutMs))
                    return false;
            }

            if (empty) {
                log() << "directory [" << filename << "] doesn't have any *.js files" << endl;
                return false;
            }

            return true;
        }

        File f;
        f.open(filename.c_str(), true);
        fileofs fo = f.len();
        if (fo > kMaxJsFileLength) {
            warning() << "attempted to execute javascript file larger than 2GB" << endl;
            return false;
        }
        unsigned len = static_cast<unsigned>(fo);
        boost::scoped_array<char> data (new char[len+1]);
        data[len] = 0;
        f.read(0, data.get(), len);

        int offset = 0;
        if (data[0] == '#' && data[1] == '!') {
            const char* newline = strchr(data.get(), '\n');
            if (!newline)
                return true; // file of just shebang treated same as empty file
            offset = newline - data.get();
        }

        StringData code(data.get() + offset, len - offset);
        return exec(code, filename, printResult, reportError, timeoutMs);
    }
コード例 #10
0
ファイル: featureBits.c プロジェクト: davidhoover/kent
bool inclChrom(char *name)
/* check if a chromosome should be included */
{
return  !((noRandom && (endsWith(name, "_random")
                        || startsWith("chrUn", name)
                        || sameWord("chrNA", name) /* danRer */
                        || sameWord("chrU", name)))  /* dm */
          || (noHap && haplotype(name)));
}
コード例 #11
0
void FileListerWithSuffix::filterFiles() {
	vector<string> temp = this->fileList;
	this->fileList.clear();
	for (vector<string>::iterator itr = temp.begin(); itr != temp.end(); ++itr) {
		if (endsWith(*itr, this->suffix)) {
			fileList.push_back(*itr);
		}
	}
}
コード例 #12
0
ファイル: discoveryphase.cpp プロジェクト: bjoernv/client
bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString &path, RemotePermissions remotePerm)
{
    if (_syncOptions._confirmExternalStorage && !_syncOptions._newFilesAreVirtual
        && remotePerm.hasPermission(RemotePermissions::IsMounted)) {
        // external storage.

        /* Note: DiscoverySingleDirectoryJob::directoryListingIteratedSlot make sure that only the
         * root of a mounted storage has 'M', all sub entries have 'm' */

        // Only allow it if the white list contains exactly this path (not parents)
        // We want to ask confirmation for external storage even if the parents where selected
        if (_selectiveSyncWhiteList.contains(path + QLatin1Char('/'))) {
            return false;
        }

        emit newBigFolder(path, true);
        return true;
    }

    // If this path or the parent is in the white list, then we do not block this file
    if (findPathInList(_selectiveSyncWhiteList, path)) {
        return false;
    }

    auto limit = _syncOptions._newBigFolderSizeLimit;
    if (limit < 0 || _syncOptions._newFilesAreVirtual) {
        // no limit, everything is allowed;
        return false;
    }

    // Go in the main thread to do a PROPFIND to know the size of this folder
    qint64 result = -1;

    {
        QMutexLocker locker(&_vioMutex);
        emit doGetSizeSignal(path, &result);
        _vioWaitCondition.wait(&_vioMutex);
    }

    if (result >= limit) {
        // we tell the UI there is a new folder
        emit newBigFolder(path, false);
        return true;
    } else {
        // it is not too big, put it in the white list (so we will not do more query for the children)
        // and and do not block.
        auto p = path;
        if (!p.endsWith(QLatin1Char('/'))) {
            p += QLatin1Char('/');
        }
        _selectiveSyncWhiteList.insert(std::upper_bound(_selectiveSyncWhiteList.begin(),
                                           _selectiveSyncWhiteList.end(), p),
            p);

        return false;
    }
}
コード例 #13
0
ファイル: winfile.c プロジェクト: cs50/spl
void createDirectory(string path) {
   if (endsWith(path, "/")) {
      path = substring(path, 0, stringLength(path) - 2);
   }
   if (_mkdir(path) != 0) {
      if (errno == EEXIST && isDirectory(path)) return;
      error("createDirectory: %s", strerror(errno));
   }
}
コード例 #14
0
ファイル: pathmatch.cpp プロジェクト: MarcelNehring/cppcheck
bool PathMatch::match(const std::string &path) const
{
    if (path.empty())
        return false;

    for (std::vector<std::string>::const_iterator i = mExcludedPaths.begin(); i != mExcludedPaths.end(); ++i) {
        const std::string excludedPath((!Path::isAbsolute(path) && Path::isAbsolute(*i)) ? Path::getRelativePath(*i, mWorkingDirectory) : *i);

        std::string findpath = Path::fromNativeSeparators(path);
        if (!mCaseSensitive)
            std::transform(findpath.begin(), findpath.end(), findpath.begin(), ::tolower);

        // Filtering directory name
        if (endsWith(excludedPath,'/')) {
            if (!endsWith(findpath,'/'))
                findpath = removeFilename(findpath);

            if (excludedPath.length() > findpath.length())
                continue;
            // Match relative paths starting with mask
            // -isrc matches src/foo.cpp
            if (findpath.compare(0, excludedPath.size(), excludedPath) == 0)
                return true;
            // Match only full directory name in middle or end of the path
            // -isrc matches myproject/src/ but does not match
            // myproject/srcfiles/ or myproject/mysrc/
            if (findpath.find("/" + excludedPath) != std::string::npos)
                return true;
        }
        // Filtering filename
        else {
            if (excludedPath.length() > findpath.length())
                continue;
            // Check if path ends with mask
            // -ifoo.cpp matches (./)foo.c, src/foo.cpp and proj/src/foo.cpp
            // -isrc/file.cpp matches src/foo.cpp and proj/src/foo.cpp
            if (findpath.compare(findpath.size() - excludedPath.size(), findpath.size(), excludedPath) == 0)
                return true;

        }
    }
    return false;
}
コード例 #15
0
ファイル: Index.cpp プロジェクト: sietse/otter-browser
void Index::processDesktopInDirectory(const std::string &baseDirectory, const std::string &relative, const std::vector<file> &content)
{
	for (std::vector<std::string>::size_type i = 0; i < content.size(); ++i)
	{
		if (content.at(i).type == FileType::File && endsWith(content.at(i).name, std::string(".desktop")))
		{
			processDesktopFile(baseDirectory, relative + content.at(i).name);
		}
	}
}
コード例 #16
0
ファイル: nibbParseImageDir.c プロジェクト: blumroy/kentUtils
void stripSuffix(char *s, char *suffix)
/* Strip suffix if it is present in s */
{
if (endsWith(s, suffix))
    {
    int suffLen = strlen(suffix);
    int sLen = strlen(s);
    s[sLen - suffLen] = 0;
    }
}
コード例 #17
0
ファイル: filelister.cpp プロジェクト: matthiaskrgr/cppcheck
void FileLister::addFiles(std::map<std::string, std::size_t> &files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored)
{
    if (!path.empty()) {
        std::string corrected_path = path;
        if (endsWith(corrected_path, '/'))
            corrected_path.erase(corrected_path.end() - 1);

        addFiles2(files, corrected_path, extra, recursive, ignored);
    }
}
コード例 #18
0
void addBed(char *file, struct hash *fileHash)
{
char name[128];

if (!endsWith(file, ".bed"))
    errAbort("filenames in bed list must end in '.bed'");

splitPath(file, NULL, name, NULL);
hashAdd(fileHash, name, readBed(file));
}
コード例 #19
0
ファイル: cdb_backup_state.c プロジェクト: 50wu/gpdb
/*
 * AssignSortVal: maps the pssible notifications to integers in the proper order
 */
int
assignSortVal(const PGnotify *pNotify)
{
	if (endsWith(pNotify->relname, SUFFIX_START))
		return 0;
	else if (endsWith(pNotify->relname, SUFFIX_SET_SERIALIZABLE))
		return 1;
	else if (endsWith(pNotify->relname, SUFFIX_GOTLOCKS))
		return 2;
	else if (endsWith(pNotify->relname, SUFFIX_SUCCEED))
		return 3;
	else if (endsWith(pNotify->relname, SUFFIX_FAIL))
		return 4;
	else
	{
		assert(false);
		return 5;
	}
}
コード例 #20
0
ファイル: virusClick.c プロジェクト: bowhan/kent
static void mkChimerax(char *item, char *pdbUrl, char *scriptFile, struct tempName *chimerax)
/* generate a chimerax file for downloading h1n1 PDB structure */
{
// chimera doesn't handle compressed files via URL, so uncompress into the trash
struct tempName tmpPdb;
char usePdbUrl[PATH_LEN];
if (endsWith(pdbUrl, ".gz") || endsWith(pdbUrl, ".Z"))
    {
    h1n1DownloadPdb(item, pdbUrl, &tmpPdb);
    h1n1MkChimeraxTrashFullUrl(&tmpPdb, usePdbUrl, sizeof(usePdbUrl));
    }
else
    safecpy(usePdbUrl, sizeof(usePdbUrl), pdbUrl);
char *pyScript = NULL;
if (scriptFile != NULL)
    pyScript = mkChimeraPyScript(scriptFile);
lsSnpPdbChimeraGenericLink(usePdbUrl, pyScript, "hgct", item, chimerax);
freeMem(pyScript);
}
コード例 #21
0
ファイル: SString.cpp プロジェクト: wolfspelz/Apollo
String& String::makeTrailingSlash(const char* szAppend)
{
#if defined(WIN32)
  if (!endsWith("\\") && !endsWith("/")) {
#else
  if (!endsWith("/")) {
#endif
    String sAppend;
    if (szAppend != 0) {
      sAppend = szAppend;
    } else {
      sAppend = filenamePathSeparator();
    }
    append(sAppend);
  }

  return *this;
}

String String::reverse(const char* szText)
{
  String sText = szText;
  String sReverse;

  int nLength = sText.bytes();
  Flexbuf<char> buf(nLength);
  char* p = (char*) sText.c_str();
  char* q = (char*) buf + nLength;
  while (*p != 0) {
    int n = UTF8_CharSize(p);
    q -= n;
    switch (n) {
      case 3: *q++ = *p++;
      case 2: *q++ = *p++;
      case 1: *q++ = *p++;
    }
    q -= n;
  }

  sReverse.set((char*) buf, nLength);
  return sReverse;
}
コード例 #22
0
ファイル: SettingHelpers.cpp プロジェクト: cozza13/hifi
QSettings::SettingsMap jsonDocumentToVariantMap(const QJsonDocument& document) {
    if (!document.isObject()) {
        qWarning() << "Settings file does not contain a JSON object";
        return QSettings::SettingsMap();
    }
    auto object = document.object();
    QSettings::SettingsMap map;

    for (auto it = object.begin(); it != object.end(); ++it) {

        QVariant result;

        if (!it->isString()) {
            result = it->toVariant();
        } else {
            auto string = it->toString();

            if (string.startsWith(QLatin1String("@@"))) { // Standard string starting with '@'
                result = QVariant(string.mid(1));

            } else if (string.startsWith(QLatin1Char('@'))) { // Custom type to string

                if (string.endsWith(QLatin1Char(')'))) {

                    if (string.startsWith(QLatin1String("@ByteArray("))) {
                        result = QVariant(string.toLatin1().mid(11, string.size() - 12));

                    } else if (string.startsWith(QLatin1String("@Variant("))) {
                        QByteArray a(string.toLatin1().mid(9));
                        QDataStream stream(&a, QIODevice::ReadOnly);
                        stream.setVersion(QDataStream::Qt_4_0);
                        stream >> result;

                    } else if (string.startsWith(QLatin1String("@Rect("))) {
                        QStringList args = splitArgs(string, 5);
                        if (args.size() == 4) {
                            result = QRect(args[0].toInt(), args[1].toInt(),
                                           args[2].toInt(), args[3].toInt());
                        }

                    } else if (string.startsWith(QLatin1String("@Size("))) {
                        QStringList args = splitArgs(string, 5);
                        if (args.size() == 2) {
                            result = QSize(args[0].toInt(), args[1].toInt());
                        }

                    } else if (string.startsWith(QLatin1String("@Point("))) {
                        QStringList args = splitArgs(string, 6);
                        if (args.size() == 2) {
                            result = QPoint(args[0].toInt(), args[1].toInt());
                        }
                    }
                }
            } else { // Standard string
コード例 #23
0
ファイル: midend.cpp プロジェクト: ederollora/p4c
 bool convert(const IR::Type_Enum* type) const override {
     if (type->name == "PSA_PacketPath_t")
         return true;
     if (type->srcInfo.isValid()) {
         auto sourceFile = type->srcInfo.getSourceFile();
         if (sourceFile.endsWith(filename))
             // Don't convert any of the standard enums
             return false;
     }
     return true;
 }
コード例 #24
0
ファイル: libstring.c プロジェクト: RaphaelBaskerville/latino
void lat_endsWith(lat_vm* vm)
{
  lat_object* b = lat_pop_stack(vm);
  lat_object* a = lat_pop_stack(vm);
  if (endsWith(lat_get_str_value(a), lat_get_str_value(b))){
    vm->regs[255] = vm->true_object;
  }
  else{
    vm->regs[255] = vm->false_object;
  }
}
コード例 #25
0
ファイル: seqcons_options.cpp プロジェクト: Garonenur/seqan
void SeqConsOptions::checkConsistency()
{
    // Position information is only available when input is in SAM format and is required for
    // position-/contig-based consensus and realignment.
    seqan::CharString inFileLowerCase = inputFile;
    seqan::toLower(inFileLowerCase);
    if ((operation == POS_CONSENSUS || operation == CTG_CONSENSUS || operation == REALIGN) &&
        (!endsWith(inFileLowerCase, ".sam")))
        throw std::runtime_error("SAM input required for coordinates.  Either specify SAM file for the "
                                 "input or use \"--method overlap_consensus\" or \"--method align_consensus\".");
}
コード例 #26
0
ファイル: Loaders.cpp プロジェクト: BlueSplash/ppsspp
FileLoader *ResolveFileLoaderTarget(FileLoader *fileLoader) {
	IdentifiedFileType type = Identify_File(fileLoader);
	if (type == FILETYPE_PSP_PBP_DIRECTORY && !endsWith(fileLoader->Path(), "/EBOOT.PBP")) {
		std::string ebootFilename = fileLoader->Path() + "/EBOOT.PBP";

		// Switch fileLoader to the actual EBOOT.
		delete fileLoader;
		fileLoader = ConstructFileLoader(ebootFilename);
	}
	return fileLoader;
}
コード例 #27
0
bool ScintillaEditor::modifyNumber(int key)
{
	int line, index;
	qsci->getCursorPosition(&line, &index);
	auto text=qsci->text(line);

	int lineFrom, indexFrom, lineTo, indexTo;
	qsci->getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);
	auto hadSelection=qsci->hasSelectedText();

	auto begin=QRegExp("[-+]?\\d*\\.?\\d*$").indexIn(text.left(index));
	auto end=text.indexOf(QRegExp("[^0-9.]"),index);
	if (end<0) end=text.length();
	auto nr=text.mid(begin,end-begin);
	if ( !(nr.contains(QRegExp("^[-+]?\\d*\\.?\\d*$")) && nr.contains(QRegExp("\\d"))) ) return false;
	auto sign=nr[0]=='+'||nr[0]=='-';
	if (nr.endsWith('.')) nr=nr.left(nr.length()-1);
	auto curpos=index-begin;
	auto dotpos=nr.indexOf('.');
	auto decimals=dotpos<0?0:nr.length()-dotpos-1;
	auto number=(dotpos<0)?nr.toLongLong():(nr.left(dotpos)+nr.mid(dotpos+1)).toLongLong();
	auto tail=nr.length()-curpos;
	auto exponent=tail-((dotpos>=curpos)?1:0);
	long long int step=1;
	for (int i=exponent; i>0; i--) step*=10;

	switch (key) {
		case Qt::Key_Up:   number+=step; break;
		case Qt::Key_Down: number-=step; break;
	}
	auto negative=number<0;
	if (negative) number=-number;
	auto newnr=QString::number(number);
	if (decimals) {
		if (newnr.length()<=decimals) newnr.prepend(QString(decimals-newnr.length()+1,'0'));
		newnr=newnr.left(newnr.length()-decimals)+"."+newnr.right(decimals);
	}
	if (tail>newnr.length()) {
		newnr.prepend(QString(tail-newnr.length(),'0'));
	}
	if (negative) newnr.prepend('-');
	else if (sign) newnr.prepend('+');
	qsci->setSelection(line, begin, line, end);
	qsci->replaceSelectedText(newnr);

	qsci->selectAll(false);
	if (hadSelection)
	{
		qsci->setSelection(lineFrom, indexFrom, lineTo, indexTo);
	}
	qsci->setCursorPosition(line, begin+newnr.length()-tail);
	emit previewRequest();
	return true;
}
コード例 #28
0
ファイル: hgTablesTest.c プロジェクト: elmargb/kentUtils
void hgTablesTest(char *url, char *logName)
/* hgTablesTest - Test hgTables web page. */
{
/* Get default page, and open log. */
struct htmlPage *rootPage = htmlPageGet(url);
if (appendLog)
    logFile = mustOpen(logName, "a");
else
    logFile = mustOpen(logName, "w");
if (! endsWith(url, "hgTables"))
    warn("Warning: first argument should be a complete URL to hgTables, "
	 "but doesn't look like one (%s)", url);
htmlPageValidateOrAbort(rootPage);

/* Go test what they've specified in command line. */
if (clDb != NULL)
    {
    testDb(rootPage, NULL, clDb);
    }
else
    {
    struct htmlForm *mainForm;
    struct htmlFormVar *orgVar;
    if ((mainForm = htmlFormGet(rootPage, "mainForm")) == NULL)
	errAbort("Couldn't get main form");
    if ((orgVar = htmlFormVarGet(mainForm, "org")) == NULL)
	errAbort("Couldn't get org var");
    if (clOrg != NULL)
	testOrg(rootPage, mainForm, clOrg);
    else
	{
	struct slName *org;
	int orgIx;
	for (org = orgVar->values, orgIx=0; org != NULL && orgIx < clOrgs; 
		org = org->next, ++orgIx)
	    {
	    testOrg(rootPage, mainForm, org->name);
	    }
	}
    }

/* Do some more complex tests on uniProt. */
testJoining(rootPage);
testFilter(rootPage);
testIdentifier(rootPage);

/* Clean up and report. */
htmlPageFree(&rootPage);
slReverse(&tablesTestList);
reportSummary(tablesTestList, stdout);
reportAll(tablesTestList, logFile);
fprintf(logFile, "---------------------------------------------\n");
reportSummary(tablesTestList, logFile);
}
コード例 #29
0
ファイル: linker.cpp プロジェクト: mleise/ldc
static std::string getOutputName(bool const sharedLib)
{
    if (!sharedLib && global.params.exefile)
    {
        return global.params.exefile;
    }

    if (sharedLib && global.params.objname)
    {
        return global.params.objname;
    }

    // Output name is inferred.
    std::string result;

    // try root module name
    if (Module::rootModule)
        result = Module::rootModule->toChars();
    else if (global.params.objfiles->dim)
        result = FileName::removeExt(static_cast<const char*>(global.params.objfiles->data[0]));
    else
        result = "a.out";

    if (sharedLib)
    {
        std::string libExt = std::string(".") + global.dll_ext;
        if (!endsWith(result, libExt))
        {
            if (global.params.targetTriple.getOS() != llvm::Triple::Win32)
                result = "lib" + result + libExt;
            else
                result.append(libExt);
        }
    }
    else if (global.params.targetTriple.isOSWindows() && !endsWith(result, ".exe"))
    {
        result.append(".exe");
    }

    return result;
}
コード例 #30
0
ファイル: udcTest.c プロジェクト: cestmoi7/AGAPE
char *getSparseFileName(char *url)
/* Return the path to sparseData cache file for url. */
{
struct slName *sl, *cacheFiles = udcFileCacheFiles(url, udcDefaultDir());
char *sparseFileName = NULL;
for (sl = cacheFiles; sl != NULL; sl = sl->next)
    if (endsWith(sl->name, "sparseData"))
	sparseFileName = sl->name;
if (sparseFileName == NULL)
    errAbort("can't find sparseData file in udcFileCacheFiles(%s) results", url);
return sparseFileName;
}