Example #1
0
boolean Logger::setupFile()
{
    if (!fileRef.isOpen())  //file not open. Try to open it.
    {
        String filename;
        if (settings.appendFile == 1)
        {
            filename = String(settings.fileNameBase);
            filename.concat(".");
            filename.concat(settings.fileNameExt);
            fileRef.open(filename.c_str(), O_APPEND | O_WRITE);
        }
        else {
            filename = String(settings.fileNameBase);
            filename.concat(settings.fileNum++);
            filename.concat(".");
            filename.concat(settings.fileNameExt);
            EEPROM.write(EEPROM_PAGE, settings); //save settings to save updated filenum
            fileRef.open(filename.c_str(), O_CREAT | O_TRUNC | O_WRITE);
        }
        if (!fileRef.isOpen())
        {
            Logger::error("open failed");
            return false;
        }
    }

    //Before we add the next frame see if the buffer is nearly full. if so flush it first.
    if (fileBuffWritePtr > BUF_SIZE - 40)
    {
        flushFileBuff();
    }
    return true;
}
Example #2
0
//---------------------------------------------------------------------------
void __fastcall TLine::Button1Click(TObject *Sender)
{
        if (RadioButton2->Checked == true)
        {
                quest->keygen = StrToInt(Edit3->Text);
        }

  quest->amin=StrToInt(Edit1->Text);
  quest->amax=StrToInt(Edit2->Text);
//  quest->dim = StrToInt(Edit5->Text);

  quest->nquest=1;
  quest->nzad=1;

  String p = String("  ");
  String s = Edit1->Text + p + Edit2->Text; //+ p + Edit5->Text;
  quest->strpar1=strdup(s.c_str());

  s = Edit1->Text + p + Edit2->Text; //+ p + Edit5->Text;
  quest->strpar2 = strdup(s.c_str());

  TList* plist = new TList();
  quest->Print(plist);

  Memo1->Clear();

  for(int i=0;i<plist->Count;i++){
    Memo1->Lines->Append(String((char*)plist->Items[i]));
  }

}
Example #3
0
U32String convertToU32String(const char *fromCode, const String &string) {
	// Apparently UTF-32 isn't native endian. Also, UCS−4−INTERNAL fails
	// for me.
	iconv_t handle = iconv_open(
#ifdef SCUMM_BIG_ENDIAN
		"UTF-32BE",
#else
		"UTF-32LE",
#endif
		fromCode);
	if (handle == ((iconv_t)-1))
		error("Failed to initialize UTF-32 conversion from %s", fromCode);

	size_t inSize = string.size();
	size_t outSize = inSize * 4; // Approximation
	size_t originalOutSize = outSize;

	Common::ScopedArray<char> buffer(new char[outSize]);
	char *dst = buffer.get();

#ifdef ICONV_USES_CONST
	const char *src = string.c_str();
#else
	char *src = const_cast<char *>(string.c_str());
#endif

	if (iconv(handle, &src, &inSize, &dst, &outSize) == ((size_t)-1))
		error("Failed to convert %s to UTF-32 string", fromCode);

	U32String output((const U32String::value_type *)buffer.get(), (originalOutSize - outSize) / 4);

	iconv_close(handle);

	return output;
}
Example #4
0
bool VirtualKeyboard::loadKeyboardPack(const String &packName) {
	_kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight());

	delete _fileArchive;
	_fileArchive = 0;
	_loaded = false;

	bool opened = false;
	if (ConfMan.hasKey("vkeybdpath"))
		opened = openPack(packName, FSNode(ConfMan.get("vkeybdpath")));
	else if (ConfMan.hasKey("extrapath"))
		opened = openPack(packName, FSNode(ConfMan.get("extrapath")));

	// fallback to the current dir
	if (!opened)
		opened = openPack(packName, FSNode("."));

	if (opened) {
		_parser->setParseMode(VirtualKeyboardParser::kParseFull);
		_loaded = _parser->parse();

		if (_loaded) {
			printf("Keyboard pack '%s' loaded successfully!\n", packName.c_str());
		} else {
			warning("Error parsing the keyboard pack '%s'", packName.c_str());

			delete _fileArchive;
			_fileArchive = 0;
		}
	} else {
		warning("Keyboard pack not found");
	}

	return _loaded;
}
Example #5
0
Sp<AIOStream> ZipFileSystem::open(const String& uri, AIOStream::Mode mode){
	if(!PHYSFS_exists(uri.c_str())){
		LOGW("File \"%s\" does not exist in zip archive", uri.c_str());
	}

	return new ZipInputStream(PHYSFS_openRead(uri.c_str()));
}
Example #6
0
bool File::rmPath(const String &path) {
	/***
	 * rmPath(): Recursively removes the given path.
	 *    On success (and also if the path doesn't exist), true is returned.
	 */
	DIR *dir;
	struct dirent *ent;
	
	if ((dir = opendir(path.c_str())) == NULL) {
		return true;
	}
	
	while ((ent = readdir(dir)) != NULL) {
		if (ent->d_type == DT_DIR) {
			if ((strcmp(ent->d_name, ".") != 0) &&
					(strcmp(ent->d_name, "..") != 0)) {
				if (! rmPath(path + "/" + ent->d_name)) {
					return false;
				}
			}
		} else if (::unlink((path + "/" + ent->d_name).c_str()) != 0) {
			return false;
		}
	}
	
	closedir(dir);
	if (::rmdir(path.c_str()) != 0) {
		return false;
	}
	
	return true;
}
Example #7
0
	//--------------------------------
	bool Utils::copyFile( const String &source, const String &destination )
	{
		bool copystatus = false;

#ifdef COLLADABU_OS_WIN
		SystemType type = getSystemType();
		if( type != WINDOWS )
			return false;

		char command[4097];
		sprintf(command,"copy \"%s\" \"%s\"", source.c_str(), destination.c_str() );
		size_t length = strlen(command);
		if( length > 4096)
			return false;

		int status = system(command);
        copystatus = (status == 0 ? true : false);
#else
		SystemType type = getSystemType();
		if( type != POSIX )
			return false;

        char command[4097];
        sprintf(command, "/bin/cp \"%s\" \"%s\"", source.c_str(), destination.c_str());
        size_t length = strlen(command);
        if( length > 4096)
            return false;
        
        
        int status = system(command);
        copystatus = (status == 0 ? true : false);
#endif

		return copystatus;
	}
Example #8
0
/**
IsValidE32Image: Checks whether the given file is E32 image

@internalComponent
@released

@param aFile - Input file name
*/
TBool Sis2Iby::IsValidE32Image(String aFile)
{
    std::ifstream aIfs;
    TInt8 aSig[5];
    TUint32 e32SigOffset = 0x10, fileSize = 0;
    TBool validE32 = EFalse;

    TrimQuotes(aFile);

    aIfs.open(aFile.c_str(), std::ios::in | std::ios::binary);

    if( !aIfs.is_open() )
    {
        throw SisUtilsException(aFile.c_str(),"Cannot open file");
    }

    aIfs.seekg(0,std::ios::end);
    fileSize = aIfs.tellg();
    if(fileSize > 20)
    {
        aIfs.seekg(e32SigOffset,std::ios::beg);
        aIfs.read((char*)aSig, 4);
        aSig[4] = '\0';

        if(!strcmp((char*)aSig, "EPOC"))
        {
            validE32 = ETrue;
        }
    }

    aIfs.close();

    return validE32;
}
Example #9
0
/**
ProcessSisFile: Processes the input sis file
  Invoke the DUMPSIS tool to extract the sis file contents
  Creates package parser object for each of the package file

@internalComponent
@released
*/
void Sis2Iby::ProcessSisFile()
{
    TUint32 retStatus = STAT_SUCCESS;
    String sisFile = SisFileName();

    if(IsVerboseMode())
    {
        std::cout << "Processing " << sisFile.c_str() << std::endl;
    }

    if(IsFileExist(sisFile))
    {
        retStatus = InvokeExtractTool(sisFile);

        switch(retStatus)
        {
        case STAT_SUCCESS:
        {
            UpdatePkgFileMap(iExtractPath, sisFile);
        }
        break;
        case STAT_FAILURE:
        {
            throw SisUtilsException(sisFile.c_str(),"Failed to extract SIS file");
        }
        }
    }
    else
        throw SisUtilsException(sisFile.c_str(),"File not found");
}
Example #10
0
void HDF5Impl::atdelete(const String& atlabel)
{
    if (!atexists(atlabel))
        CV_Error_(Error::StsInternal,("The attribute '%s' does not exist!", atlabel.c_str()));

    H5Adelete(m_h5_file_id, atlabel.c_str());
}
Example #11
0
void HDF5Impl::atread(String* value, const String& atlabel)
{
    if (!value)
        CV_Error(Error::StsBadArg, "NULL pointer");

    if (!atexists(atlabel))
        CV_Error_(Error::StsInternal, ("Attribute '%s' does not exist!", atlabel.c_str()));

    hid_t attr = H5Aopen(m_h5_file_id, atlabel.c_str(), H5P_DEFAULT);
    hid_t atype = H5Aget_type(attr);
    H5T_class_t type_class = H5Tget_class(atype);
    if (type_class != H5T_STRING)
    {
        H5Tclose(atype);
        H5Aclose(attr);
        CV_Error_(Error::StsInternal, ("Attribute '%s' is not of string type!", atlabel.c_str()));
    }
    size_t size = H5Tget_size(atype);
    AutoBuffer<char> buf(size);

    hid_t atype_mem = H5Tget_native_type(atype, H5T_DIR_ASCEND);
    H5Aread(attr, atype_mem, buf.data());
    if (size > 0 && buf[size - 1] == '\0')
        size--;
    value->assign(buf.data(), size);

    H5Tclose(atype_mem);
    H5Tclose(atype);
    H5Aclose(attr);
}
bool CvCascadeParams::scanAttr( const String prmName, const String val )
{
    bool res = true;
    if( !prmName.compare( "-stageType" ) )
    {
        for( int i = 0; i < (int)(sizeof(stageTypes)/sizeof(stageTypes[0])); i++ )
            if( !val.compare( stageTypes[i] ) )
                stageType = i;
    }
    else if( !prmName.compare( "-featureType" ) )
    {
        for( int i = 0; i < (int)(sizeof(featureTypes)/sizeof(featureTypes[0])); i++ )
            if( !val.compare( featureTypes[i] ) )
                featureType = i;
    }
    else if( !prmName.compare( "-w" ) )
    {
        winSize.width = atoi( val.c_str() );
    }
    else if( !prmName.compare( "-h" ) )
    {
        winSize.height = atoi( val.c_str() );
    }
    else
        res = false;
    return res;
}
		void addAll(bool bCreatedirevent)
		{
            if (bCreatedirevent) {
                // add base dir
                int fd = open(mDirName.c_str(), O_RDONLY);
                EV_SET(&mDirKevent, fd, EVFILT_VNODE,
                       EV_ADD | EV_ENABLE | EV_CLEAR,
                       NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
                       0, 0);
            }
			
			//fprintf(stderr, "ADDED: %s\n", mDirName.c_str());			
			
			// scan directory and call addFile(name, false) on each file
			DIR* dir = opendir(mDirName.c_str());
			if(!dir)
				return;
			
			struct dirent* entry;
			struct stat attrib;
			while((entry = readdir(dir)) != NULL)
			{
                std::string fname = (mDirName.m_string + "/" + std::string(entry->d_name));
				stat(fname.c_str(), &attrib);
				if(S_ISREG(attrib.st_mode))
					addFile(fname);
				//else
				//	fprintf(stderr, "NOT ADDED: %s (%d)\n", fname.c_str(), attrib.st_mode);

			}//end while
			
			closedir(dir);
		}
Example #14
0
String Interpreter::Process(String &command,String &object,String &room,int node, Room* r)
{
	if(strcmp(command.c_str(),"") != 0 && strcmp(object.c_str(),"") != 0)
	{
		if(strcmp(room.c_str(),"TreatmentRoom") == 0)
		{
			Room::Answer result = r->allowedCommand(command,object,node);
		
			//switch (result.result)
			//{
			//case 0:
			//	//Ivalid object with command at node
			//	return result.answer;
			//case 1:
			//	//Invalid command with valid object
			//	return result.answer;
			//case 2:
			//	//Valid command with valid object
			//	return result.answer;
			//default:
			//	//Invalid node
				return result.answer;
			
			//}
	
			//return "";
		}
	}
		return "";
}
Example #15
0
		void addFile(const String& name, bool imitEvents = true)
		{
			//fprintf(stderr, "ADDED: %s\n", name.c_str());
			
			// create entry
			struct stat attrib;
			stat(name.c_str(), &attrib);
			
			int fd = open(name.c_str(), O_RDONLY);

			if(fd == -1)
				throw FileNotFoundException(name);
			
			++mChangeListCount;
			
			char* namecopy = new char[name.length() + 1];
			strncpy(namecopy, name.c_str(), name.length());
			namecopy[name.length()] = 0;
			EntryStruct* entry = new EntryStruct(namecopy, attrib.st_mtime);
			
			// set the event data at the end of the list
			EV_SET(&mChangeList[mChangeListCount], fd, EVFILT_VNODE,
				   EV_ADD | EV_ENABLE | EV_ONESHOT,
				   NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB,
				   0, (void*)entry);
			
			// qsort
			qsort(mChangeList + 1, mChangeListCount, sizeof(KEvent), comparator);
			
			// handle action
			if(imitEvents)
				handleAction(name, Action::Add);
		}
Example #16
0
//----------------------------------------------------------------------------
// MQTT client callback, topic=<client-id>/... msg=...
//----------------------------------------------------------------------------
void ICACHE_FLASH_ATTR mqttOnPublish(String strTopic, String strMsg)
{
  tUint32 cbTopic = strTopic.length(), cbMsg = strMsg.length();

  do {
    // make sure topic starts with <client-id>
    Debug.logTxt(CLSLVL_MQTT | 0x0000, "mqttOnPublish,topic=%s,msg=%s", strTopic.c_str(), strMsg.c_str());
    if (strTopic.startsWith(AppSettings.mqttClientId + "/") == 0) {
      Debug.logTxt(CLSLVL_MQTT | 0x0010, "mqttOnPublish,not for us,dropping");
      g_mqttPktRxDropped++;
      return;
      } // if

    g_mqttPktRx++;

    // copy topic/msg to modifiable buffer on stack
    tChar szTopic[cbTopic + 1], szMsg[cbMsg + 1];
    tChar *pTopic = szTopic;
    gstrcpy(szTopic, strTopic.c_str());
    gstrcpy(szMsg, strMsg.c_str());

    // pass topic=<pfx>/<obj>... on to GPIOD
    pTopic += (AppSettings.mqttClientId.length() + 1);
    gpiodOnMqttPublish(pTopic, szMsg);
    } while (FALSE);

  } // mqttOnPublish
Example #17
0
    bool Directory::CreateDirectory(const String& path) 
	{
		DWORD dwAttrib = ::GetFileAttributesW(path.c_str());
		if  (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) return true;
		
		return CreateDirectory(path.c_str());
    }
Example #18
0
    void initializeLogger (Logger **pLogger, const char *pszLogDir, const char *pszLogFileName,
                           const char *pszTimestamp, bool bEnableScreenOutput)
    {
        if ((pLogger == NULL) || (pszLogFileName == NULL) || (pszTimestamp == NULL)) {
            return;
        }
        if ((*pLogger) == NULL) {
            (*pLogger) = new Logger();
            (*pLogger)->setDebugLevel (Logger::L_LowDetailDebug);

            // Screen output
            if (bEnableScreenOutput) {
                (*pLogger)->enableScreenOutput();
            }

            // File output
            String filename ((pszLogDir == NULL) ? "" : pszLogDir);
            if (filename.length() > 0) {
                filename += getPathSepCharAsString();
            }
            filename += pszTimestamp;
            filename += "-";
            filename += pszLogFileName;
            (*pLogger)->initLogFile (filename.c_str(), false);
            (*pLogger)->enableFileOutput();
            printf ("Enabled logging on file %s\n", filename.c_str());

            // Network output
            (*pLogger)->initNetworkLogging ("127.0.0.1");
            (*pLogger)->enableNetworkOutput (Logger::L_LowDetailDebug);
        }
    }
Example #19
0
	//--------------------------------
	bool Utils::directoryExists( const String &pathString )
	{
		bool pathExists = false;

#ifdef COLLADABU_OS_WIN
		SystemType type = getSystemType();
		if( type != WINDOWS )
			return false;

		const char* currentPath = _getcwd( 0, 0);
		const char* testPath = pathString.c_str();

		pathExists = _chdir( testPath ) == 0;
		_chdir( currentPath );
		return pathExists;
#else
		SystemType type = getSystemType();
		if( type != POSIX )
			return false;

        struct stat st;
        if(stat(pathString.c_str(),&st) == 0)
            pathExists = true;
        
#endif

		return pathExists;
	}
Example #20
0
void SmartWifi::SetupWifi(){
  EEPROM.begin(512);
  
  delay(10);
  printer->println();
  printer->println();
  printer->println("Startup");
  // read eeprom for ssid and pass
  String* credentials = getWifiCredentials();
  deviceId = getDeviceId()[0];
  String esid = credentials[0];
  String epass = credentials[1];
  printer->println("returned from function");
  printer->println("ssid "+ esid);
  printer->println("pass "+ epass);
  printer->println("deviceId "+ deviceId);
 
  if ( esid != "") {
      WiFi.mode(WIFI_STA);
      WiFi.disconnect();
      WiFi.begin(esid.c_str(), epass.c_str());
      if (testWifiConnection()) {

        //launchWeb(0);
        return;
      } 
  }
  setupMode = true;
  setupAP();
}
Example #21
0
void VariantToBsonConverter::_convertRegex(bson_t *bson, const char *key, Object v)
{
	String regex = v.o_get(s_MongoBsonRegex_pattern, false, s_MongoBsonRegex_className).toString();
	String flags = v.o_get(s_MongoBsonRegex_flags, false, s_MongoBsonRegex_className).toString();

	bson_append_regex(bson, key, -1, regex.c_str(), flags.c_str());
}
Example #22
0
void ResourceManager::removeResource(const String& path)
{
	auto key = MurmurHash64(path.c_str(), path.size(), 0);
	removeResource(key);

	LogInfo("Unloaded resource: %s", path.c_str());
}
Example #23
0
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
	FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
	bool exists = f && f->is_open();

	String tempFile = get_user_data_dir();
	if (!exists)
		return FAILED;

	if (p_path.begins_with("res://")) {
		if (PackedData::get_singleton()->has_path(p_path)) {
			print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str());
			return ERR_INVALID_PARAMETER;
		} else {
			p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path());
		}
	} else if (p_path.begins_with("user://"))
		p_path = p_path.replace("user:/", get_user_data_dir());

	memdelete(f);

	print("Playing video: %S\n", p_path.c_str());
	if (_play_video(p_path, p_volume, p_audio_track, p_subtitle_track))
		return OK;
	return FAILED;
}
Example #24
0
void cv::viz::writeCloud(const String& file, InputArray cloud, InputArray colors, InputArray normals, bool binary)
{
    CV_Assert(file.size() > 4 && "Extension is required");
    String extension = file.substr(file.size()-4);

    vtkSmartPointer<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New();
    source->SetColorCloudNormals(cloud, colors, normals);

    vtkSmartPointer<vtkWriter> writer;
    if (extension == ".xyz")
    {
        writer = vtkSmartPointer<vtkXYZWriter>::New();
        vtkXYZWriter::SafeDownCast(writer)->SetFileName(file.c_str());
    }
    else if (extension == ".ply")
    {
        writer = vtkSmartPointer<vtkPLYWriter>::New();
        vtkPLYWriter::SafeDownCast(writer)->SetFileName(file.c_str());
        vtkPLYWriter::SafeDownCast(writer)->SetFileType(binary ? VTK_BINARY : VTK_ASCII);
        vtkPLYWriter::SafeDownCast(writer)->SetArrayName("Colors");
    }
    else if (extension == ".obj")
    {
        writer = vtkSmartPointer<vtkOBJWriter>::New();
        vtkOBJWriter::SafeDownCast(writer)->SetFileName(file.c_str());
    }
    else
        CV_Error(Error::StsError, "Unsupported format");

    writer->SetInputConnection(source->GetOutputPort());
    writer->Write();
}
Example #25
0
static void report_pipe_cb(int fd, void *) {
	String s;
	if(read_string(report_pipe[0], s) <= 0)
		return;

	/* check if the message started with 'FAILED' and see it as error */
	if(strncmp(s.c_str(), "FAILED", 6) == 0) {
		win->hide();

		const char *str = s.c_str();
		str += 6; /* do not show our header */

		alert(str);
	}

	progress->copy_label(s.c_str());

	/* marked as completed successfully */
	if(s == "DONE") {
		win->hide();
		message(_("The report was sent successfully. Thank you for your contribution"));

		/* the only case when data was submitted correctly */
		data_submitted = true;
		return;
	} 
	
	/* marked as canceled */
	if(s == "CANCELED")
		win->hide();
}
Example #26
0
void cObserver::SetMemoryID(const String sharedMemoryID)
{
    try
    {
        //Create a shared memory object.
        m_SharedMemoryObject = windows_shared_memory(open_only, sharedMemoryID.c_str(), read_write);

        //Map the whole shared memory in this process
        m_MappedRegion = mapped_region(m_SharedMemoryObject, read_write);

        size_t bufferSize = (m_MappedRegion.get_size() - RESERVE_SIZE)/2;

        //First we'll set the timestamps and key:
        m_ServerTimestamp = (boost::posix_time::ptime *)m_MappedRegion.get_address();
        m_ClientTimestamp = (boost::posix_time::ptime *)m_ServerTimestamp + sizeof(boost::posix_time::ptime);

        m_Key = (Char *)m_ClientTimestamp + sizeof(boost::posix_time::ptime);
        m_BufferSize = (U64 *)(m_Key + sizeof(Char[cEntity::KEY_SIZE_IN_BYTES]));

        //Set the buffer pointers to the two halves of the allocated shared memory.

        //Note that the outbound and inbound bufferes are the opposite of the server!
        //This means that our read buffer is the server's write buffer,
        //and our write buffer is the server's read buffer.
        U8 *outboundBufferAddress = (U8 *)m_BufferSize + sizeof(U64);
        U8 *inboundBufferAddress = outboundBufferAddress + bufferSize;

    }
    catch(interprocess_exception &ex)
    {
        shared_memory_object::remove(sharedMemoryID.c_str());
        std::cout << ex.what() << std::endl;
    }

}
Example #27
0
void ff::Module::LoadTypeLibs()
{
    assertRet(_typeLibs.IsEmpty());

    // Index zero is for no type lib
    _typeLibs.Push(ComPtr<ITypeLib>());

#if !METRO_APP
    String path = GetPath();

    for (size_t i = 1; ; i++)
    {
        ComPtr<ITypeLib> typeLib;
        if (::FindResource(_instance, MAKEINTRESOURCE(i), L"TYPELIB"))
        {
            String pathIndex = String::format_new(L"%s\\%lu", path.c_str(), i);
            verify(SUCCEEDED(::LoadTypeLibEx(pathIndex.c_str(), REGKIND_NONE, &typeLib)));
        }
        else
        {
            break;
        }

        _typeLibs.Push(typeLib);
    }
#endif
}
Example #28
0
		void addAll()
		{
			// add base dir
			int fd = open(mDirName.c_str(), O_RDONLY);
			EV_SET(&mChangeList[0], fd, EVFILT_VNODE,
				   EV_ADD | EV_ENABLE | EV_ONESHOT,
				   NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_ATTRIB,
				   0, 0);
			
			//fprintf(stderr, "ADDED: %s\n", mDirName.c_str());			
			
			// scan directory and call addFile(name, false) on each file
			DIR* dir = opendir(mDirName.c_str());
			if(!dir)
				throw FileNotFoundException(directory);
			
			struct dirent* entry;
			struct stat attrib;
			while((entry = readdir(dir)) != NULL)
			{
				String fname = (mDirName + "/" + String(entry->d_name));
				stat(fname.c_str(), &attrib);
				if(S_ISREG(attrib.st_mode))
					addFile(fname, false);
				//else
				//	fprintf(stderr, "NOT ADDED: %s (%d)\n", fname.c_str(), attrib.st_mode);

			}//end while
			
			closedir(dir);
		}
Example #29
0
//---------------------------------------------------------------------------
void CIter::Insert(String text)
{
  if(myown)
    component->Insert(text.c_str(), &itr);
  else
    component->Insert(text.c_str());
}
Example #30
0
void
DropHelper::writeToDir(const String& destination, DragFileList& fileList, String& data)
{
    LOG((CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), destination.c_str()));

    if (!destination.empty() && !fileList.empty()) {
        std::fstream file;
        String dropTarget = destination;
#ifdef SYSAPI_WIN32
        dropTarget.append("\\");
#else
        dropTarget.append("/");
#endif
        dropTarget.append(fileList.at(0).getFilename());
        file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
        if (!file.is_open()) {
            LOG((CLOG_ERR "drop file failed: can not open %s", dropTarget.c_str()));
        }
        
        file.write(data.c_str(), data.size());
        file.close();

        LOG((CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), destination.c_str()));

        fileList.clear();
    }
    else {
        LOG((CLOG_ERR "drop file failed: drop target is empty"));
    }
}