int
main(int argc, const char *argv[]) {
    int i;

    UNCALL_INIT();

    for (i = 0; i < 10000; i++) {
        path1();
        path2();
        path1();
    }

    UNCALL_DEINIT();
    return 0;
}
Esempio n. 2
0
bool CViewDatabase::SetViewState(const std::string &path, int window, const CViewState &state, const std::string &skin)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    std::string path1(path);
    URIUtils::AddSlashAtEnd(path1);
    if (path1.empty()) path1 = "root://";

    std::string sql = PrepareSQL("select idView from view where window = %i and path='%s' and skin='%s'", window, path1.c_str(), skin.c_str());
    m_pDS->query(sql);
    if (!m_pDS->eof())
    { // update the view
      int idView = m_pDS->fv("idView").get_asInt();
      m_pDS->close();
      sql = PrepareSQL("update view set viewMode=%i,sortMethod=%i,sortOrder=%i,sortAttributes=%i where idView=%i",
        state.m_viewMode, (int)state.m_sortDescription.sortBy, (int)state.m_sortDescription.sortOrder, (int)state.m_sortDescription.sortAttributes, idView);
      m_pDS->exec(sql);
    }
    else
    { // add the view
      m_pDS->close();
      sql = PrepareSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder, sortAttributes, skin) values(NULL, '%s', %i, %i, %i, %i, %i, '%s')",
        path1.c_str(), window, state.m_viewMode, (int)state.m_sortDescription.sortBy, (int)state.m_sortDescription.sortOrder, (int)state.m_sortDescription.sortAttributes, skin.c_str());
      m_pDS->exec(sql);
    }
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on path '%s'", __FUNCTION__, path.c_str());
  }
  return true;
}
void 
HCopyFile(const HFileSpec& inFile1, const HFileSpec& inFile2, bool inFailIfExists)
{
	if (HasUnicode())
	{
		std::wstring path1(inFile1.GetWCharPath());
		std::wstring path2(inFile2.GetWCharPath());
		::CopyFileW(path1.c_str(), path2.c_str(), inFailIfExists);
	}
	else
	{
		std::string path1(inFile1.GetCharPath());
		std::string path2(inFile2.GetCharPath());
		::CopyFileA(path1.c_str(), path2.c_str(), inFailIfExists);
	}
}
void LibraryLoaderTest::findDSOAndCallEntryPointTest()
{
   try
   {
      std::vector<std::string> path1(1, std::string(MODULE_DIR));

      vpr::LibraryPtr dso;
      vpr::LibraryLoader::findDSOAndCallEntryPoint("loadermod1", path1,
                                                   mModules[0].second,
                                                   (bool(*)(void*)) rawCallback,
                                                   dso);
      CPPUNIT_ASSERT(dso.get() != NULL);
   }
   catch (vpr::Exception&)
   {
      CPPUNIT_ASSERT(false);
   }

   try
   {
      std::vector<fs::path> path2(1, fs::path(std::string(MODULE_DIR), fs::native));

      vpr::LibraryPtr dso;
      vpr::LibraryLoader::findDSOAndCallEntryPoint("loadermod1", path2,
                                                   mModules[0].second,
                                                   (bool(*)(void*)) rawCallback,
                                                   dso);
      CPPUNIT_ASSERT(dso.get() != NULL);
   }
   catch (vpr::Exception&)
   {
      CPPUNIT_ASSERT(false);
   }
}
void	PathTest::testPath() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPath() begin");
	Path	path1("/usr/local/bin/test");
	CPPUNIT_ASSERT(path1.size() == 5);
	CPPUNIT_ASSERT(path1[0] == "");
	CPPUNIT_ASSERT(path1[1] == "usr");
	CPPUNIT_ASSERT(path1[2] == "local");
	CPPUNIT_ASSERT(path1[3] == "bin");
	CPPUNIT_ASSERT(path1[4] == "test");
	CPPUNIT_ASSERT(path1.basename() == "test");
	CPPUNIT_ASSERT(path1.dirname() == "/usr/local/bin");
	Path	path2("/usr/local/bin/");
	CPPUNIT_ASSERT(path2.size() == 4);
	CPPUNIT_ASSERT(path2[0] == "");
	CPPUNIT_ASSERT(path2[1] == "usr");
	CPPUNIT_ASSERT(path2[2] == "local");
	CPPUNIT_ASSERT(path2[3] == "bin");
	CPPUNIT_ASSERT(path2.basename() == "bin");
	CPPUNIT_ASSERT(path2.dirname() == "/usr/local");
	Path	path3("blubb/bla/foo");
	CPPUNIT_ASSERT(path3.size() == 3);
	CPPUNIT_ASSERT(path3[0] == "blubb");
	CPPUNIT_ASSERT(path3[1] == "bla");
	CPPUNIT_ASSERT(path3[2] == "foo");
	CPPUNIT_ASSERT(path3.basename() == "foo");
	CPPUNIT_ASSERT(path3.dirname() == "blubb/bla");
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPath() end");
}
Esempio n. 6
0
bool CViewDatabase::SetViewState(const CStdString &path, int window, const CViewState &state)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    CStdString path1(path);
    CUtil::AddSlashAtEnd(path1);
    if (path1.IsEmpty()) path1 = "root://";

    CStdString sql = FormatSQL("select idView from view where window = %i and path like '%s'", window, path1.c_str());
    m_pDS->query(sql.c_str());
    if (!m_pDS->eof())
    { // update the view
      long idView = m_pDS->fv("idView").get_asLong();
      m_pDS->close();
      sql = FormatSQL("update view set viewMode=%i,sortMethod=%i,sortOrder=%i where idView=%i", state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder, idView);
      m_pDS->exec(sql.c_str());
    }
    else
    { // add the view
      m_pDS->close();
      sql = FormatSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder) values(NULL, '%s', %i, %i, %i, %i)", path1.c_str(), window, state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder);
      m_pDS->exec(sql.c_str());
    }
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s failed on path '%s'", __FUNCTION__, path.c_str());
  }
  return true;
}
Esempio n. 7
0
bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState &state)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    CStdString path1(path);
    CUtil::AddSlashAtEnd(path1);
    if (path1.IsEmpty()) path1 = "root://";

    CStdString sql = FormatSQL("select * from view where window = %i and path like '%s'", window, path1.c_str());
    m_pDS->query(sql.c_str());

    if (!m_pDS->eof())
    { // have some information
      state.m_viewMode = m_pDS->fv("viewMode").get_asInteger();
      state.m_sortMethod = (SORT_METHOD)m_pDS->fv("sortMethod").get_asInteger();
      state.m_sortOrder = (SORT_ORDER)m_pDS->fv("sortOrder").get_asInteger();
      m_pDS->close();
      return true;
    }
    m_pDS->close();
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s, failed on path '%s'", __FUNCTION__, path.c_str());
  }
  return false;
}
Esempio n. 8
0
bool CViewDatabase::GetViewState(const std::string &path, int window, CViewState &state, const std::string &skin)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    std::string path1(path);
    URIUtils::AddSlashAtEnd(path1);
    if (path1.empty()) path1 = "root://";

    std::string sql;
    if (skin.empty())
      sql = PrepareSQL("select * from view where window = %i and path='%s'", window, path1.c_str());
    else
      sql = PrepareSQL("select * from view where window = %i and path='%s' and skin='%s'", window, path1.c_str(), skin.c_str());
    m_pDS->query(sql);

    if (!m_pDS->eof())
    { // have some information
      state.m_viewMode = m_pDS->fv("viewMode").get_asInt();
      state.m_sortDescription.sortBy = (SortBy)m_pDS->fv("sortMethod").get_asInt();
      state.m_sortDescription.sortOrder = (SortOrder)m_pDS->fv("sortOrder").get_asInt();
      state.m_sortDescription.sortAttributes = (SortAttribute)m_pDS->fv("sortAttributes").get_asInt();
      m_pDS->close();
      return true;
    }
    m_pDS->close();
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s, failed on path '%s'", __FUNCTION__, path.c_str());
  }
  return false;
}
Esempio n. 9
0
int
main(int argc, const char *argv[]) {
    int i;
    int logfd;

    logfd = open("basic_flow.log", O_RDWR | O_CREAT | O_TRUNC, 0666);
    uncall_context_init(&ctx, 16, logfd);

    for (i = 0; i < 10000; i++) {
        path1();
        path2();
        path1();
    }

    uncall_context_destroy(&ctx);
    close(logfd);
}
Esempio n. 10
0
BOOL 
HMoveFile(const HFileSpec& inFileFrom, const HFileSpec& inFileTo)
{
	BOOL result;
	if (HasUnicode())
	{
		std::wstring path1(inFileFrom.GetWCharPath());
		std::wstring path2(inFileTo.GetWCharPath());
		result = ::MoveFileW(path1.c_str(), path2.c_str());
	}
	else
	{
		std::string path1(inFileFrom.GetCharPath());
		std::string path2(inFileTo.GetCharPath());
		result = ::MoveFileA(path1.c_str(), path2.c_str());
	}
	return result;
}
Esempio n. 11
0
int 
main(int, char **)
{
  KsString serverloc("//terra/tserver");
  KsString path1("/vendor");
  
  KsGetPPParams gpp;
  gpp.path = path1;
  gpp.type_mask = KS_OT_ANY;
  gpp.name_mask = "*";

  KsGetPPResult gpr;

  // connect to server in order to create a proxy object
  //
  KscVariable var(serverloc + "/vendor/server_name");
  if(!var.getProjPropsUpdate()) {
    cout << "cannot read variable" << endl;
  }
  KscServerBase *pserver = var.getServer();

  // now test requestService() with getPP
  //
  if( pserver->requestService("ks_core", 1, 0, &gpp, &gpr) ) {
    cout << "request succeeded" << endl;
    cout << "results: " << gpr.result << endl;
    PltListIterator<KsProjPropsHandle> *pit = gpr.items.newIterator();
    while(*pit) {
      KsProjPropsHandle temp(**pit);
      print_pp(temp);
      ++(*pit);
    }
    delete pit;
  } else {
    cout << "request failed" << endl;
    cout << "error code : " << pserver->getLastResult() << endl;
  }
  
  // test requestService() with extension "ks_test"
  //
  KsCreateParams cop;
  cop.name = "new_var";
  KsCreateResult cor;

  if( pserver->requestService("ks_test", KS_CREATEOBJECT_MINOR_OPCODE,
                              0, &cop, &cor) ) {
    cout << "request succeeded" << endl;
    cout << "result: " << cor.result << endl;
  } else {
    cout << "request failed" << endl;
    cout << "error code : " << pserver->getLastResult() << endl;
  }

  return 0;
}
Esempio n. 12
0
    String appendPath (const String& path, const String& subpath)
    {
        if (isAbsolutePath (subpath))
            return unixStylePath (subpath);

        String path1 (unixStylePath (path));
        if (! path1.endsWithChar ('/'))
            path1 << '/';

        return path1 + unixStylePath (subpath);
    }
Esempio n. 13
0
void factor_vm::primitive_save_image()
{
	/* do a full GC to push everything into tenured space */
	primitive_compact_gc();

	data_root<byte_array> path2(ctx->pop(),this);
	path2.untag_check(this);
	data_root<byte_array> path1(ctx->pop(),this);
	path1.untag_check(this);
	save_image((vm_char *)(path1.untagged() + 1 ),(vm_char *)(path2.untagged() + 1));
}
Esempio n. 14
0
v8::Handle<v8::Value> Util::addPath( const v8::Arguments& args ) {
	if ( args.Length() < 1 ) {
		return v8::Undefined();
	} else if ( args.Length() < 2 ) {
		return args[0];
	} else {
		v8::String::Utf8Value path1( args[0] );
		v8::String::Utf8Value path2( args[1] );

		return v8::String::NewSymbol( addPath( *path1, *path2 ).c_str() );
	}
}
static int main_(int argc, char** argv)
{
    { for(int i = 1; i < argc; ++i)
    {
        char const* const arg = argv[i];

    }}

	winstl::temporary_directory dir;

	winstl::path path1(dir);
	winstl::path path2(dir);

	path1 /= "abc";
	path2 /= "def";

	stlsoft::scoped_handle<char const*> scoper3(path1.c_str(), ::remove);
	stlsoft::scoped_handle<char const*> scoper4(path2.c_str(), ::remove);

	HANDLE hFile = winstl::file_create_always(path1.c_str(), GENERIC_WRITE, 0, 0);

	if(INVALID_HANDLE_VALUE == hFile)
	{
		fprintf(stderr, "could not open %s: %s\n", path1.c_str(), winstl::error_desc().c_str());

		return EXIT_FAILURE;
	}
	else
	{
		stlsoft::scoped_handle<HANDLE> scoper1(hFile, ::CloseHandle, INVALID_HANDLE_VALUE);

		;
	}

	DWORD numLinks1;
	DWORD numLinks2;

	winstl::hard_link_count_links(path1.c_str(), &numLinks1);

	if(!winstl::hard_link_create(path2.c_str(), path1.c_str()))
	{
		fprintf(stderr, "failed: %s\n", winstl::error_desc().c_str());
	}

	winstl::hard_link_count_links(path1.c_str(), &numLinks2);

//		tmpnam

    /* . */
    return EXIT_SUCCESS;
}
Esempio n. 16
0
void LibraryLoaderTest::findDSOTest()
{
   vpr::LibraryPtr dso1, dso2;
   std::vector<std::string> path1(1);

   path1[0] = std::string(MODULE_DIR);
   dso1 = vpr::LibraryLoader::findDSO("loadermod1", path1);
   CPPUNIT_ASSERT(dso1.get() != NULL);

   std::vector<fs::path> path2(1);
   path2[0] = fs::path(std::string(MODULE_DIR), fs::native);
   dso2 = vpr::LibraryLoader::findDSO("loadermod1", path2);
   CPPUNIT_ASSERT(dso2.get() != NULL);
}
Esempio n. 17
0
// A version of the above but prepending 'cwd' (current path) first
// if 'path' is relative
wxString wxGetRealPath(const wxString& cwd, const wxString& path)
{
    wxString path1(path);

    if (!wxIsAbsolutePath(path))
    {
        path1 = cwd;
        if (path1.Last() != wxFILE_SEP_PATH)
            path1 += wxFILE_SEP_PATH;
        path1 += path;
    }

    return wxGetRealPath(path1);
}
Esempio n. 18
0
File: fs.cpp Progetto: kyusof/SilkJS
static JSVAL fs_cmp(JSARGS args) {
    HandleScope scope;
    String::Utf8Value path1(args[0]->ToString());
    String::Utf8Value path2(args[1]->ToString());
    int fd;
    long size1, size2;
    char buf[1024];

    fd = open(*path1, O_RDONLY);
    if (fd < 0) {
        sprintf(buf, "Could not open %s", *path1);
        return scope.Close(String::New(buf));
    }
    size1 = lseek(fd, 0, 2);
    lseek(fd, 0, 0);
    unsigned char buf1[size1];
    if (read(fd, buf1, size1) != size1) {
        close(fd);
        sprintf(buf, "Error reading %s", *path1);
        return scope.Close(String::New(buf));
    }
    close(fd);

    fd = open(*path2, O_RDONLY);
    if (fd < 0) {
        sprintf(buf, "Could not open %s", *path2);
        return scope.Close(String::New(buf));
    }
    size2 = lseek(fd, 0, 2);
    lseek(fd, 0, 0);
    unsigned char buf2[size2];
    if (read(fd, buf2, size2) != size2) {
        close(fd);
        sprintf(buf, "Error reading %s", *path2);
        return scope.Close(String::New(buf));
    }
    close(fd);

    if (size1 != size2) {
        return scope.Close(String::New("Files differ in size"));
    }

    for (long n=0; n<size1; n++) {
        if (buf1[n] != buf2[n]) {
            sprintf(buf, "Files differ at offset %ld", n);
            return scope.Close(String::New(buf));
        }
    }
    return scope.Close(True());
}
Esempio n. 19
0
    const String appendPath (const String& path, const String& subpath)
    {
        if (File::isAbsolutePath (subpath)
             || subpath.startsWithChar ('$')
             || subpath.startsWithChar ('~')
             || (CharacterFunctions::isLetter (subpath[0]) && subpath[1] == ':'))
            return subpath.replaceCharacter ('\\', '/');

        String path1 (path.replaceCharacter ('\\', '/'));
        if (! path1.endsWithChar ('/'))
            path1 << '/';

        return path1 + subpath.replaceCharacter ('\\', '/');
    }
Esempio n. 20
0
void printPathWithoutRecursive(int path[v][v],int n)
	 {
		int i,j;
		for(i=0;i<n;i++)
		  {
		    for(j=0;j<n;j++)
		      {
				  printf("Shortest path Between (%d , %d):",i,j);
				  path1(i,j);
				  printf("\t  Cost of path::%d",graph[i][j]);
				  printf("\n");
				  				    
			  }
		  } 
	 }
Esempio n. 21
0
TEST(Path, pwd)
{
    cxx::sys::Path path1(cxx::sys::Path::curpath());
    printf("current path is: %s\n", path1.name());

    cxx::sys::Path path2(cxx::sys::Path::curpath());
    path2.append("abc");
    printf("path2 is: %s\n", path2.name());

    cxx::sys::Path path3("abc/");
    printf("path3 is: %s\n", path3.name());

    cxx::sys::Path path6("../");
    printf("path6 is: %s\n", path6.name());
}
Esempio n. 22
0
/**
 * @brief Find the CDiffContext diffpos of an item from its left & right paths
 * @return POSITION to item, NULL if not found.
 * @note Filenames must be same, if they differ NULL is returned.
 */
UINT_PTR CDirDoc::FindItemFromPaths(LPCTSTR pathLeft, LPCTSTR pathRight)
{
	LPCTSTR file1 = paths_FindFileName(pathLeft);
	LPCTSTR file2 = paths_FindFileName(pathRight);

	// Filenames must be identical
	if (lstrcmpi(file1, file2) != 0)
		return NULL;

	String path1(pathLeft, file1 - pathLeft); // include trailing backslash
	String path2(pathRight, file2 - pathRight); // include trailing backslash

	// Path can contain (because of difftools?) '/' and '\'
	// so for comparing purposes, convert whole path to use '\\'
	replace_char(&*path1.begin(), '/', '\\');
	replace_char(&*path2.begin(), '/', '\\');

	String base1 = m_pCtxt->GetLeftPath(); // include trailing backslash
	if (path1.compare(0, base1.length(), base1.c_str()) != 0)
		return NULL;
	path1.erase(0, base1.length()); // turn into relative path
	if (String::size_type length = path1.length())
		path1.resize(length - 1); // remove trailing backslash

	String base2 = m_pCtxt->GetRightPath(); // include trailing backslash
	if (path2.compare(0, base2.length(), base2.c_str()) != 0)
		return NULL;
	path2.erase(0, base2.length()); // turn into relative path
	if (String::size_type length = path2.length())
		path2.resize(length - 1); // remove trailing backslash

	UINT_PTR pos = m_pCtxt->GetFirstDiffPosition();
	while (UINT_PTR currentPos = pos) // Save our current pos before getting next
	{
		const DIFFITEM &di = m_pCtxt->GetNextDiffPosition(pos);
		if (di.left.path == path1 &&
			di.right.path == path2 &&
			di.left.filename == file1 &&
			di.right.filename == file2)
		{
			return currentPos;
		}
	}
	return 0;
}
Esempio n. 23
0
PsimagLite::String pathPrepend(PsimagLite::String pre,PsimagLite::String pathname)
{
	bool addDotDot = false;
	PsimagLite::String path1("");
	if (pathname.length() > 2 && pathname[0] == '.' && pathname[1] == '.') {
		addDotDot = true;
		path1 = pathname.substr(2,pathname.length());
	}

	if (pathname.length() > 1 && pathname[0] == '/') path1 = pathname;

	if (path1 == "") return pre + pathname;

	size_t index = path1.find_last_of("/");

	index++;
	PsimagLite::String ret = path1.substr(0,index) + pre +
	        path1.substr(index,path1.length());
	return (addDotDot) ? ".." + ret : ret;
}
Esempio n. 24
0
bool zkmutex::try_rlock() {
  pfi::concurrent::scoped_lock lk(m_);
  if (has_rlock_) {
    return has_rlock_;
  }

  string prefix = path_ + "/rlock_";
  if (!zk_.create_seq(prefix, seqfile_)) {
    return false;
  }

  if (seqfile_ == "") {
    return false;
  }

  vector<string> list;
  if (!zk_.list(path_, list) || list.empty()) {
    return false;
  }

  has_rlock_ = true;
  for (size_t i = 0; i < list.size(); i++) {
    // not exist write lock less than me.
    if (pfi::data::string::starts_with(list[i], string("wlock_"))) {
      string path1((path_ + '/' + list[i]).c_str(), prefix.size() + 16);
      if (seqfile_.compare(prefix.length(), -1, path1,
                           prefix.length(), -1) > 0) {
        has_rlock_ = false;
        break;
      }
    }
  }

  if (!has_rlock_) {
    zk_.remove(seqfile_);
  } else {
    DLOG(INFO) << "got read lock: " << seqfile_;
  }

  return has_rlock_;
}
Esempio n. 25
0
int main()
{
    boost::filesystem::path path1("abc");
    boost::filesystem::path path2("def");

    try 
    {
        boost::filesystem::rename(path1, "def");

        std::cout << "Renamed " 
                  << path1.string()
                  << " to "
                  << path2.string()
                  << std::endl;
    } 
    catch (boost::filesystem::filesystem_error e)
    {
        std::cerr << "Could not rename file " << path1.string() << std::endl;
    }
    return 0;
}
Esempio n. 26
0
DEF_TEST(SkOpBuilderFuzz665, reporter) {
    SkPath path;
    path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50));  // -5.0959e+07f, 2.32235e+07f
path.lineTo(SkBits2Float(0xcc4264b0), SkBits2Float(0x4bb12e48));  // -5.0959e+07f, 2.32234e+07f
path.lineTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50));  // -5.0959e+07f, 2.32235e+07f
path.close();
    SkPath path1(path);
    path.reset();
    path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkBits2Float(0x43213333), SkBits2Float(0x43080000));  // 161.2f, 136
path.lineTo(SkBits2Float(0x43038000), SkBits2Float(0x43080000));  // 131.5f, 136
path.cubicTo(SkBits2Float(0x43038000), SkBits2Float(0x42f00000), SkBits2Float(0x42f16666), SkBits2Float(0x42d53333), SkBits2Float(0x42d3cccd), SkBits2Float(0x42cd6666));  // 131.5f, 120, 120.7f, 106.6f, 105.9f, 102.7f
path.lineTo(SkBits2Float(0x42e33333), SkBits2Float(0x42940000));  // 113.6f, 74
    SkPath path2(path);
    SkOpBuilder builder;
    builder.add(path1, kUnion_SkPathOp);
    builder.add(path2, kUnion_SkPathOp);
    SkPath result;
    builder.resolve(&result);
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_merge__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2ZLorg_apache_subversion_javahl_types_Depth_2ZZZ
(JNIEnv *env, jobject jthis, jstring jpath1, jobject jrevision1,
 jstring jpath2, jobject jrevision2, jstring jlocalPath, jboolean jforce,
 jobject jdepth, jboolean jignoreAncestry, jboolean jdryRun,
 jboolean jrecordOnly)
{
  JNIEntry(SVNClient, merge);
  SVNClient *cl = SVNClient::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError(_("bad C++ this"));
      return;
    }
  Revision revision1(jrevision1);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder path1(jpath1);
  if (JNIUtil::isExceptionThrown())
    return;

  Revision revision2(jrevision2);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder path2(jpath2);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder localPath(jlocalPath);
  if (JNIUtil::isExceptionThrown())
    return;

  cl->merge(path1, revision1, path2, revision2, localPath,
            jforce ? true:false, EnumMapper::toDepth(jdepth),
            jignoreAncestry ? true:false, jdryRun ? true:false,
            jrecordOnly ? true:false);
}
Esempio n. 28
0
void factor_vm::primitive_save_image_and_exit()
{
	/* We unbox this before doing anything else. This is the only point
	where we might throw an error, so we have to throw an error here since
	later steps destroy the current image. */
	data_root<byte_array> path2(ctx->pop(),this);
	path2.untag_check(this);
	data_root<byte_array> path1(ctx->pop(),this);
	path1.untag_check(this);

	/* strip out special_objects data which is set on startup anyway */
	for(cell i = 0; i < special_object_count; i++)
		if(!save_special_p(i)) special_objects[i] = false_object;

	gc(collect_compact_op,
		0, /* requested size */
		false /* discard objects only reachable from stacks */);

	/* Save the image */
	if(save_image((vm_char *)(path1.untagged() + 1), (vm_char *)(path2.untagged() + 1)))
		exit(0);
	else
		exit(1);
}
Esempio n. 29
0
int main(int argc, char *argv[])
{
  // Workaround to start browser from QTextView
  qputenv( "BROWSER", "browser --url" );

  // @AP: Reset the locale that is used for number formatting to "C" locale.
  setlocale(LC_NUMERIC, "C");

#ifdef ANDROID

  // Gets the additional data directory from our app. That is normally the
  // storage path to the SD-Card as /sdcard/Cumulus.
  QString addDir = jniGetAddDataDir();

  while( addDir.isEmpty() )
    {
      qDebug() << " Waiting for Cumulus addDir ...";
      usleep(250000);
      addDir = jniGetAddDataDir();
    }

  // Assign the original path name
  addDir = QDir(addDir).canonicalPath();

  // Nice trick to overwrite the HOME directory under Android by us ;-)
  // That must be done before the QApplication constructor is called.
  // Otherwise another HOME is used by QApplication.
  qputenv ( "HOME", addDir.toLatin1().data() );

#endif

#ifndef ANDROID
#if QT_VERSION < 0x050000
  // Note this must be called before QApplication constructor
  QApplication::setGraphicsSystem( "raster" );
#endif
#endif

  QApplication app(argc, argv, true);

  QCoreApplication::setApplicationName( "Cumulus" );
  QCoreApplication::setApplicationVersion( CU_VERSION );
  QCoreApplication::setOrganizationName( "KFLog" );
  QCoreApplication::setOrganizationDomain( "www.kflog.org" );

  // Make sure the application uses utf8 encoding for translated widgets
#if QT_VERSION < 0x050000
  QTextCodec::setCodecForTr( QTextCodec::codecForName ("UTF-8") );
#endif

  // Note, that first $HOME must be overwritten under Android otherwise the
  // setting file is created/searched in the internal data area under:
  // /data/data/org.kflog.cumulus/files. That is the $HOME, set by Necessitas.
  GeneralConfig *conf = GeneralConfig::instance();

#ifdef ANDROID

  // Set the add data directory in our configuration
  conf->setDataRoot( addDir );

  // Set data directory after every startup because different Android APIs
  // uses different locations. Otherwise that can cause problems during Andoid
  // updates to a newer release.
  conf->setUserDataDirectory( addDir );

  // As next we must wait, that the add data are installed. That is done
  // at the Java side.
  while( jniAddDataInstalled() == false )
    {
      qDebug() << " Waiting for Cumulus addData installed ...";
      usleep(250000);
    }

  // Gets the internal data directory from our App
  QString appDir = jniGetAppDataDir();

  while (appDir.isEmpty())
    {
      qDebug() << " Waiting for Cumulus appDir ...";
      usleep(250000);
      appDir = jniGetAppDataDir();
    }

  conf->setAppRoot( appDir );

#endif /* ANDROID */

  // @AP: we installing our own message handler
#if QT_VERSION < 0x050000
  qInstallMsgHandler(messageHandler);
#else
  qInstallMessageHandler(messageHandler);
#endif

  // @AP: to make trace output available, if process is started via
  // QT/X11, we can redirect all output into a file, if configuration option
  // Log2File is set to true.

#ifndef ANDROID
  // @AP: make install root of Cumulus available for other modules via
  // GeneralConfig. The assumption is that Cumulus is installed at
  // <root>/bin/cumulus. The <root> path will be passed to GeneralConfig.
  QDir rootDir( QFileInfo(argv[0]).canonicalPath() );

  if( rootDir.cdUp() == false )
    {
      qWarning() << "main: Cumulus App has no parent directory! InstallDir is" << rootDir;
    }

  QString rootPath = rootDir.canonicalPath();

  conf->setAppRoot( rootPath );
#endif

#ifdef MAEMO
  bool isLog2File = true;
#else
  bool isLog2File = conf->getLog2FileMode();
#endif

  QString logDir = "/tmp";

#ifdef ANDROID

  // always log on Android for now
  isLog2File = true;
  logDir = QDir::homePath();

#endif

  if( isLog2File )
    {

#ifdef MAEMO
      // check for alternate paths under Maemo
      QDir path1("/media/mmc1"); // N8x0
      QDir path2("/media/mmc2"); // N8x0
      QDir path3("/home/user/MyDocs");

      if( path1.exists() && HwInfo::isMounted(path1.absolutePath()) )
        {
          logDir = path1.absolutePath();
        }
      else if( path2.exists() && HwInfo::isMounted(path2.absolutePath()) )
        {
          logDir = path2.absolutePath();
        }
      else if( path3.exists() )
         {
           logDir = path3.absolutePath();
         }

#endif

      logDir += "/cumulus.log";

      // Save one old log file version.
      rename( logDir.toLatin1().data(), (logDir + ".old").toLatin1().data() );

      int i = open( logDir.toLatin1().data(), O_RDWR|O_CREAT|O_TRUNC,
                    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH );

      // Duplicate file descriptors 1, 2 that the output goes into a logfile

      // dup2( i, fileno(stdin) );
      dup2( i, fileno(stdout) );
      dup2( i, fileno(stderr) );
      close(i);
    }

#ifdef ANDROID

  qDebug() << "Cumulus addDir and QtHome:" << addDir;
  qDebug() << "Cumulus appDir:" << appDir;
  qDebug() << "Cumulus LogDir:" << logDir;

#endif

  /*
    @AP: check, if environment variable LD_BIND_NOW is set. In this case reset
    it to avoid a gps client crash during fork under Opie.

    If the process environment [see exec(base operating system)] contains a
    variable named LD_BIND_NOW with a non-null value, the dynamic linker processes
    all relocations before transferring control to the program. For example, all
    the following environment entries would specify this behavior.

    * LD_BIND_NOW=1
    * LD_BIND_NOW=on
    * LD_BIND_NOW=off

    Otherwise, LD_BIND_NOW either does not occur in the environment or has a null
    value. The dynamic linker is permitted to evaluate procedure linkage table
    entries lazily, thus avoiding symbol resolution and relocation overhead for
    functions that are not called. See the Procedure Linkage Table in this chapter
    of the processor supplement for more information.
  */

  char *env = getenv("LD_BIND_NOW");
  qDebug( "LD_BIND_NOW=%s", env ? env : "NULL" );

//  if( env != 0 )
//    {
//      unsetenv("LD_BIND_NOW");
//    }

  // Load language translation file for Cumulus.

#ifndef ANDROID

  conf->setLanguage( conf->getLanguage() );

#else

  // Gets the default language from the Android device.
   QString language = jniGetLanguage();

   // Put Android's default language into the program environment.
   qputenv( "LANG",  language.toLatin1().data() );

   qDebug() << "Android sets language to" << language;

   if( language.startsWith( "de" ) )
     {
       // In case of German there is a translation available.
       conf->setLanguage( "de" );
     }
   else
     {
       conf->setLanguage( conf->getLanguage() );
     }

  QFontDatabase database;

  foreach (const QString &family, database.families())
    {
      foreach (const QString &style, database.styles(family))
        {
          QString sizes;

          foreach (int points, database.smoothSizes(family, style))
            sizes += QString::number(points) + " ";

          qDebug() << "Installed Font:" << family << style << sizes.trimmed();
        }
    }

  QHash <QString, float> dmh = jniGetDisplayMetrics();

  QHashIterator<QString, float> i(dmh);

  qDebug() << "Android display metrics as key value list";

  while( i.hasNext() )
    {
      i.next();
      qDebug() << i.key() << "=" << i.value();
    }

  QHash <QString, QString> bdh = jniGetBuildData();

  QHashIterator<QString, QString> j(bdh);

  qDebug() << "Android build data as key value list";

  while( j.hasNext() )
    {
      j.next();
      qDebug() << j.key() << "=" << j.value();
    }

#endif

  // save done configuration settings
  conf->save();

  // create the Cumulus application window
  MainWindow *cumulus = new MainWindow( Qt::WindowContextHelpButtonHint );

  // start window manager event processing loop
  int result = QApplication::exec();

  // remove as first MainWindow because class objects inside can call GeneralConfig
  delete cumulus;

  // remove GeneralConfig, it is created during first call to it
  delete GeneralConfig::instance();

  return result;
}
Esempio n. 30
0
    virtual void on_draw()
    {
        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid r(rb);
        rb.clear(agg::rgba(1, 1, 1));

        scanline_type sl;
        agg::rasterizer_scanline_aa<> ras;

        agg::simple_polygon_vertex_source path1(m_poly1.polygon(), 
                                                m_poly1.num_points(), 
                                                false, 
                                                false);

        agg::simple_polygon_vertex_source path2(m_poly2.polygon(), 
                                                m_poly2.num_points(), 
                                                false, 
                                                false);


        typedef agg::conv_bspline<agg::simple_polygon_vertex_source> conv_bspline_type;
        conv_bspline_type bspline1(path1);
        conv_bspline_type bspline2(path2);
        bspline1.interpolation_step(1.0 / m_num_points.value());
        bspline2.interpolation_step(1.0 / m_num_points.value());


        typedef agg::conv_curve<font_manager_type::path_adaptor_type>            conv_font_curve_type;
        typedef agg::conv_segmentator<conv_font_curve_type>                      conv_font_segm_type;
        typedef agg::conv_transform<conv_font_segm_type, agg::trans_double_path> conv_font_trans_type;

        agg::trans_double_path tcurve;
        conv_font_curve_type fcurves(m_fman.path_adaptor());
        conv_font_segm_type  fsegm(fcurves);
        conv_font_trans_type ftrans(fsegm, tcurve);

        tcurve.preserve_x_scale(m_preserve_x_scale.status());
        if(m_fixed_len.status()) tcurve.base_length(1140.0);
        tcurve.base_height(30.0);

        tcurve.add_paths(bspline1, bspline2);
        fsegm.approximation_scale(3.0);
        fcurves.approximation_scale(5.0);

        if(m_feng.load_font(full_file_name("timesi.ttf"), 0, agg::glyph_ren_outline))
        {
            double x = 0.0;
            double y = 3.0;
            const char* p = text;

            m_feng.hinting(false);
            m_feng.height(40);

            while(*p)
            {
                const agg::glyph_cache* glyph = m_fman.glyph(*p);
                if(glyph)
                {
                    if(x > tcurve.total_length1()) break;

                    m_fman.add_kerning(&x, &y);
                    m_fman.init_embedded_adaptors(glyph, x, y);

                    if(glyph->data_type == agg::glyph_data_outline)
                    {
                        ras.reset();
                        ras.add_path(ftrans);
                        r.color(agg::rgba8(0, 0, 0));
                        agg::render_scanlines(ras, sl, r);
                    }

                    // increment pen position
                    x += glyph->advance_x;
                    y += glyph->advance_y;
                }
                ++p;
            }
        }
        else
        {
            message("Please copy file timesi.ttf to the current directory\n"
                    "or download it from http://www.antigrain.com/timesi.zip");
        }



        typedef agg::conv_stroke<conv_bspline_type> conv_stroke_type;
        conv_stroke_type stroke1(bspline1);
        conv_stroke_type stroke2(bspline2);

        stroke1.width(2.0);
        stroke2.width(2.0);

        r.color(agg::rgba8(170, 50, 20, 100));
        ras.add_path(stroke1);
        agg::render_scanlines(ras, sl, r);

        ras.add_path(stroke2);
        agg::render_scanlines(ras, sl, r);


        //--------------------------
        // Render the "poly" tool and controls
        r.color(agg::rgba(0, 0.3, 0.5, 0.2));
        ras.add_path(m_poly1);
        agg::render_scanlines(ras, sl, r);

        ras.add_path(m_poly2);
        agg::render_scanlines(ras, sl, r);


        agg::render_ctrl(ras, sl, rb, m_fixed_len);
        agg::render_ctrl(ras, sl, rb, m_preserve_x_scale);
        agg::render_ctrl(ras, sl, rb, m_animate);
        agg::render_ctrl(ras, sl, rb, m_num_points);
        //--------------------------

    }