示例#1
0
int SmbFs::fs_mknod(const char *path, mode_t mode, dev_t dev)
{
	QMutexLocker locker(&_mutex);

	SMBCFILE *file;
	
	if(( file = (smbc_getFunctionCreat(_ctx))(_ctx, qPrintable(getPath(path)),mode) ) != NULL)
	{
		(smbc_getFunctionClose(_ctx))(_ctx, file);
		return(0);
	}
	else
		return(-errno);
}
示例#2
0
int
smbc_creat(const char *furl,
           mode_t mode)
{
	SMBCFILE * file;
	int fd;
        
        file = smbc_getFunctionCreat(statcont)(statcont, furl, mode);
	if (!file)
		return -1;
        
	fd = add_fd(file);
	if (fd == -1) {
		/* Hmm... should we delete the file too ? I guess we could try */
                smbc_getFunctionClose(statcont)(statcont, file);
                smbc_getFunctionUnlink(statcont)(statcont, furl);
	}
	return fd;
}
示例#3
0
static PyObject *
Context_creat (Context *self, PyObject *args)
{
  PyObject *largs, *lkwlist;
  char *uri;
  int mode = 0;
  File *file;
  smbc_creat_fn fn;

  if (!PyArg_ParseTuple (args, "s|i", &uri, &mode))
    {
      return NULL;
    }

  largs = Py_BuildValue ("()");
  lkwlist = PyDict_New ();
  PyDict_SetItemString (lkwlist, "context", (PyObject *) self);
  file = (File *)smbc_FileType.tp_new (&smbc_FileType, largs, lkwlist);
  if (!file)
    {
      return PyErr_NoMemory();
    }

  if (smbc_FileType.tp_init ((PyObject *)file, largs, lkwlist) < 0)
    {
      smbc_FileType.tp_dealloc ((PyObject *)file);
      return NULL;
    }

  fn = smbc_getFunctionCreat (self->context);
  errno = 0;
  file->file = (*fn) (self->context, uri, mode);
  if (!file->file)
    {
      pysmbc_SetFromErrno ();
      smbc_FileType.tp_dealloc ((PyObject *)file);
      file = NULL;
    }

  Py_DECREF (largs);
  Py_DECREF (lkwlist);
  return (PyObject *)file;
}