예제 #1
0
void MainGui::resultLoad() {
#ifdef DEBUGMSG
  qDebug("MainGui::resultLoad");
#endif
  propertyEditor->itemSelected(0);
  QString fname=QFileDialog::getOpenFileName("","*.inet",mainwidget,"Load Result");
  if (fname.isEmpty()) return;
  
  QFile fp(fname);
  if (!fp.open(IO_ReadOnly)) {
    qDebug("MainGui::resultLoad(%s): file not found",(const char*)fname);
    return;
  }
  // Clean up
  treeEditor->disconnectSlots();
  sceneViewer->disconnectSlots();
  sceneViewer->rootNode(0);
  trashViewer->disconnectSlots();
  trashViewer->rootNode(0);
  mapViewer->set(0,0);
  iNode_=0;
  map_=0;
  analysis_=0;
  readyToAna(FALSE);  //disable the analysis buttons
  interactive(FALSE); //disable the analysis buttons

  MLParser parser(&fp);
  ArgDict* args=parser.args();
  readInstanceNet(fname);
  treeEditor->connectSlots();
  sceneViewer->rootNode(iNode_);
  sceneViewer->connectSlots();
  if (iNode_) {
    float gN=iNode_->attributeFloat("geoNorth");
    float gE=iNode_->attributeFloat("geoEast");
    float gS=iNode_->attributeFloat("geoSouth");
    float gW=iNode_->attributeFloat("geoWest");
    QFileInfo finfo(fname);
    QString map=finfo.dirPath()+"/"+finfo.baseName(true)+".map";
    GeoImage* mapImage=new GeoImage(map,"Map",gW,gN,gE,gS);
    if (mapImage) {
      try {
        mapImage->load();
        mapViewer->set(iNode_,mapImage);
	 //! to do: file selection instead of hard coded image
        mapViewer->setDataImage(geoImageList_["rmk001"]);
      }
      catch (FatalError err) {
        delete mapImage;
        mapImage=0;
      }
    }
    fileInstanceNet_=fname;
    fileMap_=map;
  }
}
예제 #2
0
bool HTTPLiveStream::UpdateSizeInfo(uint16_t width, uint16_t height,
                                    uint16_t srcwidth, uint16_t srcheight)
{
    if (m_streamid == -1)
        return false;

    QFileInfo finfo(m_sourceFile);
    QString newOutBase = finfo.fileName() +
        QString(".%1x%2_%3kV_%4kA").arg(width).arg(height)
                .arg(m_bitrate/1000).arg(m_audioBitrate/1000);
    QString newFullURL = m_httpPrefix + newOutBase + ".m3u8";
    QString newRelativeURL;

    if (newFullURL.contains("/Content/GetFile"))
        newRelativeURL = "/Content/GetFile?StorageGroup=Streaming&FileName=" +
            newOutBase + ".m3u8";
    else
        newRelativeURL = newOutBase + ".m3u8";

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(
        "UPDATE livestream "
        "SET width = :WIDTH, height = :HEIGHT, "
        "    sourcewidth = :SRCWIDTH, sourceheight = :SRCHEIGHT, "
        "    fullurl = :FULLURL, relativeurl = :RELATIVEURL, "
        "    outbase = :OUTBASE "
        "WHERE id = :STREAMID; ");
    query.bindValue(":WIDTH", width);
    query.bindValue(":HEIGHT", height);
    query.bindValue(":SRCWIDTH", srcwidth);
    query.bindValue(":SRCHEIGHT", srcheight);
    query.bindValue(":FULLURL", newFullURL);
    query.bindValue(":RELATIVEURL", newRelativeURL);
    query.bindValue(":OUTBASE", newOutBase);
    query.bindValue(":STREAMID", m_streamid);

    if (!query.exec())
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("Unable to update segment info for streamid %1")
                    .arg(m_streamid));
        return false;
    }

    m_width = width;
    m_height = height;
    m_sourceWidth = srcwidth;
    m_sourceHeight = srcheight;
    m_outBase = newOutBase;
    m_fullURL = newFullURL;
    m_relativeURL = newRelativeURL;

    SetOutputVars();

    return true;
}
예제 #3
0
파일: qucs_actions.cpp 프로젝트: Qucs/qucs
// ------------------------------------------------------------------------
///
/// \brief QucsApp::editFile
/// \param File is the filename, or empty for a new file
///
/// Called by :
/// - slotTextNew()
/// - slotShowLastMsg()
/// - slotShowLastNetlist()
/// - edit properties of components (such as spice, verilog)
///
void QucsApp::editFile(const QString& File)
{
    if ((QucsSettings.Editor.toLower() == "qucs") | QucsSettings.Editor.isEmpty())
    {
        // The Editor is 'qucs' or empty, open a net document tab
        if (File.isEmpty()) {
            TextDoc *d = new TextDoc(this, "");
            int i = DocumentTab->addTab(d, QPixmap(":/bitmaps/empty.xpm"), QObject::tr("untitled"));
            DocumentTab->setCurrentIndex(i);
        }
        else
        {
            slotHideEdit(); // disable text edit of component property

            statusBar()->showMessage(tr("Opening file..."));

            QFileInfo finfo(File);

            if(!finfo.exists())
                statusBar()->showMessage(tr("Opening aborted, file not found."), 2000);
            else {
                gotoPage(File);
                lastDirOpenSave = File;   // remember last directory and file
                statusBar()->showMessage(tr("Ready."));
            }
        }
    }
    else
    {
      // use an external editor
      QString prog;
      QStringList args;

      QString editorPath = QucsSettings.Editor;
      QFileInfo editor(editorPath);
      prog = QDir::toNativeSeparators(editor.canonicalFilePath());

      if (!File.isEmpty()) {
          args << File;
      }

      QProcess *externalEditor = new QProcess();
      qDebug() << "Command: " << editorPath << args.join(" ");
      externalEditor->start(prog, args);

      if( !externalEditor->waitForStarted(1000) ) {
        QMessageBox::critical(this, tr("Error"), tr("Cannot start text editor: \n\n%1").arg(editorPath));
        delete externalEditor;
        return;
      }
      qDebug() << externalEditor->readAllStandardError();

      // to kill it before qucs ends
      connect(this, SIGNAL(signalKillEmAll()), externalEditor, SLOT(kill()));
    }
}
QString KaraokePlayable_File::absolutePath( const QString &object )
{
    if ( QFileInfo( object ).isAbsolute() )
        return object;

    // Convert to absolute path
    QFileInfo finfo( m_baseFile );

    return finfo.absoluteDir().absolutePath() + QDir::separator() + object;
}
예제 #5
0
QString get2xIconPath(const QString& path)
{
    QFileInfo finfo(path);
    QString base = finfo.baseName();
    QString ext = finfo.completeSuffix();

    QDir dir = finfo.dir();

    return dir.filePath(base + "@2x" + "." + ext);
}
예제 #6
0
static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{
  FAR const char *name;
  unsigned int index;
  int ret;

  /* Have we reached the end of the directory */

  index = dir->u.binfs.fb_index;
  name = builtin_getname(index);
  if (name == NULL)
    {
      /* We signal the end of the directory by returning the
       * special error -ENOENT
       */

      finfo("Entry %d: End of directory\n", index);
      ret = -ENOENT;
    }
  else
    {
      /* Save the filename and file type */

      finfo("Entry %d: \"%s\"\n", index, name);
      dir->fd_dir.d_type = DTYPE_FILE;
      strncpy(dir->fd_dir.d_name, name, NAME_MAX+1);

      /* The application list is terminated by an entry with a NULL name.
       * Therefore, there is at least one more entry in the list.
       */

      index++;

      /* Set up the next directory entry offset.  NOTE that we could use the
       * standard f_pos instead of our own private fb_index.
       */

      dir->u.binfs.fb_index = index;
      ret = OK;
    }

  return ret;
}
예제 #7
0
void ProjectQmlScanMonitor::fileChanged(const QString &path){
    QFileInfo finfo(path);
    if ( finfo.fileName() == "" || finfo.suffix() != "qml" || !finfo.fileName().at(0).isUpper() )
        return;
    QString fileDir = finfo.path();

    vlog_debug("editqmljs-scanmonitor", "Reseting library for file: " + path);
    ProjectQmlScope::Ptr project = m_projectScope;
    project->globalLibraries()->resetLibrary(fileDir);
    project->implicitLibraries()->resetLibrary(fileDir);
}
예제 #8
0
void ExportDialog::on_radioButton_prg_clicked()
{
    auto filename = ui->editFilename->text();

    QFileInfo finfo(filename);
    auto extension = finfo.suffix();

    filename.chop(extension.length()+1);
    filename += ".prg";
    ui->editFilename->setText(filename);
}
예제 #9
0
파일: sam_hsmci.c 프로젝트: a1ien/nuttx
bool sam_cardinserted(int slotno)
{
  bool removed;

  /* Get the state of the GPIO pin */

  removed = sam_gpioread(GPIO_MCI_CD);
  finfo("Slot %d inserted: %s\n", slotno, removed ? "NO" : "YES");

  return !removed;
}
예제 #10
0
/**
 * Set the instrument selected in the combobox based on
 * the file name of the run is possible.
 *
 * Assumes that names have the form \<instrument\>_\<run-number\>.\<ext\>
 */
void IndirectLoadILL::handleFilesFound() {
    // get first part of basename
    QString filename = m_uiForm.mwRun->getFirstFilename();
    QFileInfo finfo(filename);
    QStringList fnameParts = finfo.baseName().split('_');

    if (fnameParts.size() > 0) {
        // Check if the first part of the name is in the instruments list
        m_uiForm.iicInstrumentConfiguration->setInstrument(fnameParts[0]);
    }
}
void MyCurl::SetToSmallFile(wxString filePath) {
	//curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); /* !!! */

	wxFileName finfo(filePath);
	wxFile file(filePath, wxFile::read);
	uploadData = new char[finfo.GetSize().GetValue()];
	auto uploadDataSize = file.Read(uploadData, finfo.GetSize().GetValue());

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, uploadData);
	curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, uploadDataSize);
}
예제 #12
0
파일: ramdisk.c 프로젝트: a1ien/nuttx
static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
{
  FAR struct rd_struct_s *dev;
  FAR void **ppv = (void**)((uintptr_t)arg);

  finfo("Entry\n");

  /* Only one ioctl command is supported */

  DEBUGASSERT(inode && inode->i_private);
  if (cmd == BIOC_XIPBASE && ppv)
    {
      dev  = (FAR struct rd_struct_s *)inode->i_private;
      *ppv = (FAR void *)dev->rd_buffer;

      finfo("ppv: %p\n", *ppv);
      return OK;
    }

  return -ENOTTY;
}
예제 #13
0
파일: fs_skeleton.c 프로젝트: a1ien/nuttx
static int skel_readdir(FAR struct fs_dirent_s *dir)
{
  FAR struct skel_level1_s *level1;
  char  filename[16];
  int index;
  int ret;

  DEBUGASSERT(dir && dir->u.procfs);
  level1 = dir->u.procfs;

  /* TODO: Perform device specific readdir function here.  This may
   *       or may not involve validating the nentries variable
   *       in the base depending on the implementation.
   */

  /* Have we reached the end of the directory */

  index = level1->base.index;
  if (index >= level1->base.nentries)
    {
      /* We signal the end of the directory by returning the special
       * error -ENOENT
       */

      finfo("Entry %d: End of directory\n", index);
      ret = -ENOENT;
    }

  /* We are tranversing a subdirectory of task attributes */

  else
    {
      DEBUGASSERT(level1->base.level == 1);

      /* TODO: Add device specific entries */

      strcpy(filename, "dummy");

      /* TODO:  Specify the type of entry */

      dir->fd_dir.d_type = DTYPE_FILE;
      strncpy(dir->fd_dir.d_name, filename, NAME_MAX + 1);

      /* Set up the next directory entry offset.  NOTE that we could use the
       * standard f_pos instead of our own private index.
       */

      level1->base.index = index + 1;
      ret = OK;
    }

  return ret;
}
예제 #14
0
int impl_file_handle::close(const struct fuse_operations *ops) {
  int flush_err = 0;
  if (is_dir_) {
    if (ops->releasedir) {
      fuse_file_info finfo(make_finfo());
      ops->releasedir(get_name().c_str(), &finfo);
    }
  } else {
    if (ops->flush) {
      fuse_file_info finfo(make_finfo());
      finfo.flush = 1;
      flush_err = ops->flush(get_name().c_str(), &finfo);
    }
    if (ops->release) // Ignoring result.
    {
      fuse_file_info finfo(make_finfo());
      ops->release(get_name().c_str(), &finfo); // Set open() flags here?
    }
  }
  return flush_err;
}
예제 #15
0
bool MainWindow::reloadShader(wz_shader_type_t type, bool user_shader, QString *errMessage)
{
	m_pathvert.clear();
	m_pathfrag.clear();

	if (type == WZ_SHADER_NONE)
	{
		return true;
	}

	QString pathvert, pathfrag;
	if (user_shader)
	{
		pathvert = m_settings->value("shaders/user_vert_path").toString();
		pathfrag = m_settings->value("shaders/user_frag_path").toString();
	}
	else
	{
		switch (type)
		{
		case WZ_SHADER_WZ31:
			pathvert = WMIT_SHADER_WZ31_DEFPATH_VERT;
			pathfrag = WMIT_SHADER_WZ31_DEFPATH_FRAG;
			break;
		case WZ_SHADER_WZ32:
			pathvert = WMIT_SHADER_WZ32TC_DEFPATH_VERT;
			pathfrag = WMIT_SHADER_WZ32TC_DEFPATH_FRAG;
			break;
		default:
			break;
		}
	}

	QFileInfo finfo(pathvert);
	if (finfo.exists())
	{
		finfo.setFile(pathfrag);
		if (finfo.exists())
		{
			if (m_ui->centralWidget->loadShader(type, pathvert, pathfrag, errMessage))
			{
				m_pathvert = pathvert;
				m_pathfrag = pathfrag;
				return true;
			}
		}
		else
			*errMessage = "Unable to find fragment shader!";
	}
	else
		*errMessage = "Unable to find vertex shader!";
	return false;
}
예제 #16
0
파일: tools.cpp 프로젝트: s0lus/cuda
void getCPUInfo()
{
#ifdef _WIN32

    // Get extended ids.
    int CPUInfo[4] = {-1};
    __cpuid(CPUInfo, 0x80000000);
    unsigned int nExIds = CPUInfo[0];

    // Get the information associated with each extended ID.
    char CPUBrandString[0x40] = { 0 };
    for(unsigned int i = 0x80000000; i <= nExIds; ++i)
    {
        __cpuid(CPUInfo, i);

        // Interpret CPU brand string and cache information.
        if  (i == 0x80000002)
        {
            memcpy( CPUBrandString, CPUInfo, sizeof(CPUInfo));
        }
        else if(i == 0x80000003)
        {
            memcpy( CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
        }
        else if(i == 0x80000004)
        {
            memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
        }
    }
    std::cout << "CPU:" << CPUBrandString << std::endl;

#else

    std::string line;
    std::ifstream finfo("/proc/cpuinfo");

    while(getline(finfo, line))
    {
        std::stringstream str(line);
        std::string itype;
        std::string info;

        if (getline(str, itype, ':') && getline(str, info) && itype.substr(0, 10) == "model name")
        {
            std::cout << "CPU: " << info << std::endl;
            break;
        }
    }

    finfo.close();

#endif
}
예제 #17
0
int impl_fuse_context::flush_file_buffers(LPCWSTR /*file_name*/,
                                          PDOKAN_FILE_INFO dokan_file_info) {
  // Please note, that we ignore file_name here, because it might
  // have been retargeted by a symlink.
  impl_file_handle *hndl =
      reinterpret_cast<impl_file_handle *>(dokan_file_info->Context);
  if (!hndl)
    return -EINVAL;

  if (hndl->is_dir()) {
    if (!ops_.fsyncdir)
      return -EINVAL;
    fuse_file_info finfo(hndl->make_finfo());
    return ops_.fsyncdir(hndl->get_name().c_str(), 0, &finfo);
  } else {
    if (!ops_.fsync)
      return -EINVAL;
    fuse_file_info finfo(hndl->make_finfo());
    return ops_.fsync(hndl->get_name().c_str(), 0, &finfo);
  }
}
예제 #18
0
int impl_fuse_context::set_file_time(PCWSTR file_name, const FILETIME* creation_time,
				  const FILETIME* last_access_time, const FILETIME* last_write_time,
				  PDOKAN_FILE_INFO dokan_file_info)
{
	if (!ops_.utimens && !ops_.utime && !ops_.win_set_times) return -EINVAL;

	if (ops_.win_set_times)
	{
		std::string fname=unixify(wchar_to_utf8_cstr(file_name));
		CHECKED(check_and_resolve(&fname));

		impl_file_handle *hndl=reinterpret_cast<impl_file_handle*>(dokan_file_info->Context);
		if (!hndl)
			return ops_.win_set_times(fname.c_str(), NULL, creation_time, last_access_time, last_write_time);

		if (hndl->is_dir())
			return -EACCES;

		fuse_file_info finfo(hndl->make_finfo());

		return ops_.win_set_times(fname.c_str(), &finfo, creation_time, last_access_time, last_write_time);
	}

	if (!ops_.getattr)
		return -EINVAL;

	std::string fname=unixify(wchar_to_utf8_cstr(file_name));
	CHECKED(check_and_resolve(&fname));

	struct FUSE_STAT st={0};
	CHECKED(ops_.getattr(fname.c_str(),&st));

	if (ops_.utimens)
	{
		struct timespec tv[2]={0};
		//TODO: support nanosecond resolution
		//Access time
		CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(tv[0].tv_sec)));		
		//Modification time
		CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(tv[1].tv_sec)));

		return ops_.utimens(fname.c_str(),tv);
	} else
	{
		struct utimbuf ut={0};
		//Access time
		CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(ut.actime)));
		//Modification time
		CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(ut.modtime)));
		
		return ops_.utime(fname.c_str(),&ut);
	}
}
예제 #19
0
int do_app(u8 * file){
	s8 ret,fd;
	u8 i=0;
	u32 ch;
	u8 buff[256];
	struct fnode fn;
	u32 size;
	if (!check_for_args(APP,1)) return 1;
	fd = openf(file,O_RW);
	if(fd == -1){
		vd_puts( "CANNOT OPEN THE FILE\n");
				errormessage(geterror());
				fl_clean();
		return 1;
	}
	finfo(fd, & fn);
	size = fn.size;
	ret= seekf(fd,  size,SEEK_BEG);
	while(1){
		ch=getche();
		if(ch == 1)
			break;
        if (ch == 13 || ch == 10 ){
            printf("\n");ch='\n';
        }
		if (i == 255){
			i=0;
			ret = writef(fd,buff,256);
			if(ret == -1){
				vd_puts("SORRY SORRY CANNOT WRITE TO FILE SO REMOVING IT\n");
                errormessage(geterror());
				unlinkf(file);
                fl_clean();
				return 1;
			}
		}
		buff[i++] = (u8)ch;
	}
	ret = writef(fd,buff,i);
	if(ret == -1){
		vd_puts("SORRY SORRY CANNOT WRITE TO FILE SO REMOVING IT\n");
				errormessage(geterror());
		unlinkf(file);
				fl_clean();
		return 1;
	}
    puts(" ");
	closef(fd);
		fl_clean();
	return 0;

}
예제 #20
0
QString DataManager::getLocalCachedFile(const QString& repo_id,
                                        const QString& fpath,
                                        const QString& file_id)
{
    QString local_file_path = getLocalCacheFilePath(repo_id, fpath);
    QFileInfo finfo(local_file_path);
    if (!finfo.exists()) {
        qWarning ("No cache file for %s\n", toCStr(fpath));
        return "";
    }

    FileCache::CacheEntry entry;
    if (!filecache_->getCacheEntry(repo_id, fpath, &entry)) {
        qWarning ("No cache db entry for %s\n", toCStr(fpath));
        return "";
    }

    if (entry.file_id == file_id) {
        qWarning ("cache file id matched for %s: %s\n", toCStr(fpath), toCStr(file_id));
        return local_file_path;
    } else {
        // The file is updated on server
        qint64 mtime = finfo.lastModified().toMSecsSinceEpoch();
        bool use_cached = false;
        if (mtime != entry.seafile_mtime) {
            qWarning(
                "cache file is updated locally (mtime changed from %lld to "
                "%lld), use it: %s\n",
                entry.seafile_mtime,
                mtime,
                toCStr(fpath));
            use_cached = true;
        } else if (finfo.size() != entry.seafile_size) {
            qWarning(
                "cache file is updated locally (size changed from %lld to "
                "%lld), use it: %s\n",
                entry.seafile_size,
                finfo.size(),
                toCStr(fpath));
            use_cached = true;
        }

        if (use_cached) {
            // If the file is also updated locally, open it directly
            return local_file_path;
        } else {
            qWarning ("cache file is outdated, download newer version: %s\n", toCStr(fpath));
            // Otherwise the newer version would be downloaded
            return "";
        }
    }
}
예제 #21
0
bool RS_Graphic::saveAs(const QString &filename, RS2::FormatType type, bool force)
{
	RS_DEBUG->print("RS_Graphic::saveAs: Entering...");

	// Set to "failed" by default.
	bool ret	= false;

	// Check/memorize if file name we want to use as new file
	// name is the same as the actual file name.
	bool fn_is_same	= filename == this->filename;
	auto const filenameSaved=this->filename;
	auto const autosaveFilenameSaved=this->autosaveFilename;
	auto const formatTypeSaved=this->formatType;

	this->filename = filename;
	this->formatType	= type;

	// QString	const oldAutosaveName = this->autosaveFilename;
	QFileInfo	finfo(filename);

	// Construct new autosave filename by prepending # to the filename
	// part, using the same directory as the destination file.
	this->autosaveFilename = finfo.path() + "/#" + finfo.fileName();

	// When drawing is saved using a different name than the actual
	// drawing file name, make LibreCAD think that drawing file
	// has been modified, to make sure the drawing file saved.
	if (!fn_is_same || force)
		setModified(true);

	ret	= save();		//	Save file.

	if (ret) {
		// Save was successful, remove old autosave file.
		QFile	qf_file(autosaveFilenameSaved);

		if (qf_file.exists()) {
			RS_DEBUG->print("RS_Graphic::saveAs: Removing old autosave file %s",
							autosaveFilenameSaved.toLatin1().data());
			qf_file.remove();
		}

	}else{
		//do not modify filenames:
		this->filename=filenameSaved;
		this->autosaveFilename=autosaveFilenameSaved;
		this->formatType=formatTypeSaved;
	}

	return ret;
}
예제 #22
0
void PhotoTexturingWidget::exportCamerasToMaxScript(){
	QString dir;
	if (lastDirectory == ""){
		dir=".";
	}else{
		dir = lastDirectory;
	}
	QString filename = QFileDialog::getSaveFileName(this,tr("Select MaxScript File"),dir, "*.ms");
	if(!filename.isNull()){
		QFileInfo finfo(filename);
		lastDirectory = finfo.absolutePath();
		photoTexturer->exportMaxScript(filename,mesh);
	}
}
예제 #23
0
파일: ramdisk.c 프로젝트: a1ien/nuttx
int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors,
                     uint16_t sectsize)
#endif
{
  struct rd_struct_s *dev;
  char devname[16];
  int ret = -ENOMEM;

  finfo("buffer: %p nsectors: %d sectsize: %d\n", buffer, nsectors, sectsize);

  /* Sanity check */

#ifdef CONFIG_DEBUG_FEATURES
  if (minor < 0 || minor > 255 || !buffer || !nsectors || !sectsize)
    {
      return -EINVAL;
    }
#endif

  /* Allocate a ramdisk device structure */

  dev = (struct rd_struct_s *)kmm_zalloc(sizeof(struct rd_struct_s));
  if (dev)
    {
      /* Initialize the ramdisk device structure */

      dev->rd_nsectors     = nsectors;     /* Number of sectors on device */
      dev->rd_sectsize     = sectsize;     /* The size of one sector */
      dev->rd_buffer       = buffer;       /* RAM disk backup memory */

#ifdef CONFIG_FS_WRITABLE
      dev->rd_flags        = rdflags & RDFLAG_USER;
#endif

      /* Create a ramdisk device name */

      snprintf(devname, 16, "/dev/ram%d", minor);

      /* Inode private data is a reference to the ramdisk device structure */

      ret = register_blockdriver(devname, &g_bops, 0, dev);
      if (ret < 0)
        {
          ferr("register_blockdriver failed: %d\n", -ret);
          kmm_free(dev);
        }
    }

  return ret;
}
void QgsDelimitedTextSourceSelect::updateFileName()
{
  // put a default layer name in the text entry
  QString filename = txtFilePath->text();
  QFileInfo finfo( filename );
  if ( finfo.exists() )
  {
    QSettings settings;
    settings.setValue( mPluginKey + "/text_path", finfo.path() );
  }
  txtLayerName->setText( finfo.completeBaseName() );
  loadSettingsForFile( filename );
  updateFieldsAndEnable();
}
예제 #25
0
bool Sketch::save(const char *path)
{
    QFileInfo finfo(path);

    if (QString::compare(finfo.suffix(), "vect", Qt::CaseInsensitive) == 0)
    {
        return saveVect(path);
    } else
    {
        std::cerr << "Error: sketch file format " << finfo.suffix().toStdString()
                  << " is not supported.\n" << std::flush;
        return false;
    }
}
예제 #26
0
int stm32_sdinitialize(int minor)
{
#ifdef HAVE_MMCSD
  FAR struct spi_dev_s *spi;
  int ret;

  /* Get the SPI port */

  finfo("Initializing SPI port %d\n", STM32_MMCSDSPIPORTNO);

  spi = stm32_spibus_initialize(STM32_MMCSDSPIPORTNO);
  if (!spi)
    {
      ferr("ERROR: Failed to initialize SPI port %d\n", STM32_MMCSDSPIPORTNO);
      return -ENODEV;
    }

  finfo("Successfully initialized SPI port %d\n", STM32_MMCSDSPIPORTNO);

  /* Bind the SPI port to the slot */

  finfo("Binding SPI port %d to MMC/SD slot %d\n",
          STM32_MMCSDSPIPORTNO, STM32_MMCSDSLOTNO);

  ret = mmcsd_spislotinitialize(minor, STM32_MMCSDSLOTNO, spi);
  if (ret < 0)
    {
      ferr("ERROR: Failed to bind SPI port %d to MMC/SD slot %d: %d\n",
            STM32_MMCSDSPIPORTNO, STM32_MMCSDSLOTNO, ret);
      return ret;
    }

  finfo("Successfuly bound SPI port %d to MMC/SD slot %d\n",
        STM32_MMCSDSPIPORTNO, STM32_MMCSDSLOTNO);
#endif
  return OK;
}
예제 #27
0
static int binfs_statfs(struct inode *mountpt, struct statfs *buf)
{
  finfo("Entry\n");

  /* Fill in the statfs info */

  memset(buf, 0, sizeof(struct statfs));
  buf->f_type    = BINFS_MAGIC;
  buf->f_bsize   = 0;
  buf->f_blocks  = 0;
  buf->f_bfree   = 0;
  buf->f_bavail  = 0;
  buf->f_namelen = NAME_MAX;
  return OK;
}
예제 #28
0
static int procfs_dup(FAR const struct file *oldp, FAR struct file *newp)
{
  FAR struct procfs_file_s *oldattr;

  finfo("Dup %p->%p\n", oldp, newp);

  /* Recover our private data from the old struct file instance */

  oldattr = (FAR struct procfs_file_s *)oldp->f_priv;
  DEBUGASSERT(oldattr);

  /* Allow lower-level handler do the dup to get it's extra data */

  return oldattr->procfsentry->ops->dup(oldp, newp);
}
예제 #29
0
파일: ftl.c 프로젝트: a1ien/nuttx
static ssize_t ftl_write(FAR struct inode *inode, const unsigned char *buffer,
                        size_t start_sector, unsigned int nsectors)
{
  struct ftl_struct_s *dev;

  finfo("sector: %d nsectors: %d\n", start_sector, nsectors);

  DEBUGASSERT(inode && inode->i_private);
  dev = (struct ftl_struct_s *)inode->i_private;
#ifdef CONFIG_FTL_WRITEBUFFER
  return rwb_write(&dev->rwb, start_sector, nsectors, buffer);
#else
  return ftl_flush(dev, buffer, start_sector, nsectors);
#endif
}
예제 #30
0
파일: ramdisk.c 프로젝트: a1ien/nuttx
static int rd_open(FAR struct inode *inode)
{
  FAR struct rd_struct_s *dev;

  DEBUGASSERT(inode && inode->i_private);
  dev = (FAR struct rd_struct_s *)inode->i_private;

  /* Increment the open reference count */

  dev->rd_crefs++;
  DEBUGASSERT(dev->rd_crefs > 0);

  finfo("rd_crefs: %d\n", dev->rd_crefs);
  return OK;
}