Esempio n. 1
0
/**
 * file_exists_and_readable:
 * @filename: a #const gchar * with a file path
 *
 * tests if the file exists, and  if it is readable, the last
 * check is not reliable, it does not check all the groups you are
 * in, so change this function before you rely on that check!
 *
 * this function is Gnome-VFS aware, so it will work on URI's
 *
 * Return value: gboolean, TRUE if readable, else FALSE
 **/
gboolean file_exists_and_readable(const gchar * filename) {
	gchar *ondiskencoding;
	/* not sure the purpose of returning true here by default so I changed it to false. */
	/* gboolean retval=TRUE; */
	gboolean retval = FALSE;

#ifdef WIN32
	 if (strchr(filename,'/')==filename) filename++;
#endif /* WIN32 */

#ifdef DEVELOPMENT
	g_assert(filename);
#endif
	if (!filename || strlen(filename) < 2) {
		DEBUG_MSG("file_exists_and_readable, strlen(filename) < 2 or no filename!!!!\n");
		return FALSE;
	}
	DEBUG_MSG("file_exists_and_readable, filename(%p)=\"%s\", strlen(filename)=%d\n", filename, filename, strlen(filename));
	ondiskencoding = get_filename_on_disk_encoding(filename);
	DEBUG_MSG("file_exists_and_readable, ondiskencoding='%s'\n",ondiskencoding);
#ifdef HAVE_GNOME_VFS
	{
		GnomeVFSURI* uri;
		uri = gnome_vfs_uri_new(ondiskencoding);
		retval = gnome_vfs_uri_exists(uri);
		DEBUG_MSG("gnome_vfs_uri has path %s\n",gnome_vfs_uri_get_path(uri));
		gnome_vfs_uri_unref(uri);
		DEBUG_MSG("file_exists_and_readable, return %d for %s\n",retval,filename);
	}
#else /* HAVE_GNOME_VFS */
	{
#ifdef WIN32		
		struct _stat naamstat;
		errno = 0;
		retval = ((_stat(ondiskencoding, &naamstat) == 0) && (errno == 0));
#else /* NOT WIN32 */
		struct stat naamstat;
		errno = 0;
		retval = ((stat(ondiskencoding, &naamstat) == 0) && (errno == 0));
#endif
		DEBUG_MSG("file_exists_and_readable, retval=%d (ernno=%d) for\n %s\n",retval,errno,ondiskencoding);
	}
#endif /* HAVE_GNOME_VFS */
	g_free(ondiskencoding);
	return retval;
}
Esempio n. 2
0
TS_EXPORT int stat(const char *path, struct stat *st)
{
	const char *p;
	char buf[PATH_MAX * 2];
	static int (*_stat)(const char *path, struct stat *buf);

	if (!get_rootpath(__func__))
		return -1;

	_stat = get_libc_func("stat");

	p = trap_path(path, buf);
	if (p == NULL)
		return -1;

	return _stat(p, st);
}
Esempio n. 3
0
int STEAM_stat(const char *path, struct _stat *buf)
{
	TSteamElemInfo Info;
	int returnVal;
	struct _stat tmpBuf;
	TSteamError steamError;

	char tmpPath[_MAX_PATH];

	if ( STEAMtrackingProgress )
	{
		DoEventTic(FALSE);
	}

	strcpy(tmpPath, path);			
	FixSlashes(tmpPath);

	memset(buf, 0, sizeof(struct _stat));

	returnVal= SteamStat(tmpPath, &Info, &steamError);

	if ( returnVal == 0 )
	{
		if (Info.bIsDir )
		{
			buf->st_mode |= _S_IFDIR;
			buf->st_size = 0;
		}
		else
		{
			buf->st_mode |= _S_IFREG;
			buf->st_size = Info.uSizeOrCount;
		}

		buf->st_atime = Info.lLastAccessTime;
		buf->st_mtime = Info.lLastModificationTime;
		buf->st_ctime = Info.lCreationTime;


		_stat(path, &tmpBuf);
	}

	CheckError(NULL, &steamError);
	return returnVal;
}
Esempio n. 4
0
void Map_Snapshot()
{
  CString strMsg;
  // we need to do the following
  // 1. make sure the snapshot directory exists (create it if it doesn't)
  // 2. find out what the lastest save is based on number
  // 3. inc that and save the map
  CString strOrgPath, strOrgFile;
  ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
  AddSlash(strOrgPath);
  strOrgPath += "snapshots";
  bool bGo = true;
  struct _stat Stat;
  if (_stat(strOrgPath, &Stat) == -1)
  {
    bGo = (_mkdir(strOrgPath) != -1);
  }
  AddSlash(strOrgPath);
  if (bGo)
  {
    int nCount = 0;
    long lSize = 0;
    CString strNewPath = strOrgPath;
    strNewPath += strOrgFile;
    CString strFile;
    while (bGo)
    {
      strFile.Format("%s.%i", strNewPath, nCount);
      bGo = DoesFileExist(strFile, lSize);
      nCount++;
    }
    // strFile has the next available slot
    Map_SaveFile(strFile.GetBuffer(0), false);
		Sys_SetTitle (currentmap);
    if (lSize > 120 * 1024 * 1024) // total size of saves > 4 mb // Jonathan: bumped to 120mb
    {
      Sys_Printf("The snapshot files in the [%s] directory total more than 40 megabytes. You might consider cleaning the directory up.", strOrgPath);
    }
  }
  else
  {
    strMsg.Format("Snapshot save failed.. unabled to create directory\n%s", strOrgPath);
    g_pParentWnd->MessageBox(strMsg);
  }
}
Esempio n. 5
0
BOOL isLauncherPathValid(const char* path)
{
    char javaw[_MAX_PATH] = {0};
    BOOL result = FALSE;
    if (*path)
    {
        strcpy(javaw, path);
        appendJavaw(javaw);
        result = _stat(javaw, &statBuf) == 0;
        if (!result)
        {
            // Don't display additional info in the error popup.
            SetLastError(0);
        }
    }
    debug("Check launcher:\t%s %s\n", javaw, result ? "(OK)" : "(not found)");
    return result;
}
Esempio n. 6
0
int getinfo(char *filename, int flag) {
/*	char *s; */
	int result;

/*	if ((result = stat(filename, &statbuf)) != 0) { */
/*	if ((result = stat(filename, &statbuf[flag])) != 0) { */
	if ((result = _stat(filename, &statbuf[flag])) != 0) {
		if (flag == 0)
			fprintf(stderr, "Unable to obtain info on %s\n", filename);
		return -1;
	}
/*	timeptr = ctime(&statbuf.st_atime);	*/	/* ltime */
	timeptr = ctime(&statbuf[flag].st_atime);		/* ltime */
	lcivilize(timeptr);	
	
/*	printf("%s last modified: %s", filename, timeptr); */
	return 0;
}
Esempio n. 7
0
/* stream must be open FILE * to same filename */
long ews_fsize(const char *filename,void *stream)
{
   struct _stat filestat;
   int          result;
   long         size;

   result = _stat( filename, &filestat );
   if (result == 0) {
      /* got a filesize */
      size = filestat.st_size;
   }
   else {
      /* indicate no size found */
      size = 0;
   }

   return size;
}
Esempio n. 8
0
FileStat file_stat(const std::string &name) {
    #ifdef _MSC_VER
    struct _stat a;
    if (_stat(name.c_str(), &a) != 0) {
        user_error << "Could not stat " << name << "\n";
    }
    #else
    struct stat a;
    if (::stat(name.c_str(), &a) != 0) {
        user_error << "Could not stat " << name << "\n";
    }
    #endif
    return {static_cast<uint64_t>(a.st_size),
            static_cast<uint32_t>(a.st_mtime),
            static_cast<uint32_t>(a.st_uid),
            static_cast<uint32_t>(a.st_gid),
            static_cast<uint32_t>(a.st_mode)};
}
Esempio n. 9
0
time_t
ModTime (
    char *pName
    ) {

    struct _stat statbuf;

    if (*strbscan (pName, "?*")) {
        return 0L;
    }

    if (_stat (pName, &statbuf) == -1) {
        return 0L;
    }

    return statbuf.st_mtime;

}
Esempio n. 10
0
File: fs.c Progetto: ebugsky/node
void fs__stat(uv_fs_t* req, const char* path) {
  int result;

  req->ptr = malloc(sizeof(struct _stat));
  if (!req->ptr) {
    uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
  }

  result = _stat(path, (struct _stat*)req->ptr);
  if (result == -1) {
    free(req->ptr);
    req->ptr = NULL;
  } else {
    req->flags |= UV_FS_FREE_PTR;
  }

  SET_REQ_RESULT(req, result);
}
Esempio n. 11
0
bool UT_isRegularFile(const char* filename)
{
	struct _stat buf;

#ifdef WIN32
	WCHAR wFilename[MAX_PATH];
	MultiByteToWideChar(CP_UTF8,0,filename,-1,wFilename,MAX_PATH);
	if( _wstat( wFilename , &buf ) != -1 ) 
#else
	if( _stat( filename , &buf ) != -1 ) 
#endif
	{
		UT_DEBUGMSG(("UT_isRegularFile(%s) { _stat(...) succeeded, returning ( st_mode<%X> & _S_IFREG<%X> )!= 0  <%X>\n", filename, buf.st_mode, _S_IFREG, (( buf.st_mode & _S_IFREG ) != 0) ));
		return ( buf.st_mode & _S_IFREG ) != 0;
	}
	UT_DEBUGMSG(("UT_isRegularFile(%s) { _stat(...) failed, returning false. }\n", filename));
	return false;
}
Esempio n. 12
0
static int __stat( const char *path, FileInfo * info)
{
	int ret;
	struct _stat s;

	ret = _stat(path, &s);
	if(ret != 0)
	{
		return ret;
	}

	strcpy(info->name, path);
	info->attrib = s.st_mode;
	info->time = s.st_mtime;
	info->size = s.st_size;

	return 0;
}
Esempio n. 13
0
int do_list(char* directory, int sockfd)
{
	DIR* dirp;
	struct dirent* entry;
	char line_buffer[256], line_length;
#ifdef _WIN32
	struct _stat s;
#else
	struct stat s;
#endif

	dirp = opendir(directory);
	if (dirp == NULL) {
		line_length = rt_sprintf(line_buffer, "500 Internal Error\r\n");
		send(sockfd, line_buffer, line_length, 0);
		return -1;
	}

	while (1) {
		entry = readdir(dirp);
		if (entry == NULL) break;

		rt_sprintf(line_buffer, "%s/%s", directory, entry->d_name);
#ifdef _WIN32
		if (_stat(line_buffer, &s) ==0)
#else
		if (stat(line_buffer, &s) == 0)
#endif
		{
			if (s.st_mode & S_IFDIR)
				line_length = rt_sprintf(line_buffer, "drw-r--r-- 1 admin admin %d Jan 1 2000 %s\r\n", 0, entry->d_name);
			else
				line_length = rt_sprintf(line_buffer, "-rw-r--r-- 1 admin admin %d Jan 1 2000 %s\r\n", s.st_size, entry->d_name);

			send(sockfd, line_buffer, line_length, 0);
		} else {
			rt_kprintf("Get directory entry error\n");
			break;
		}
	}

	closedir(dirp);
	return 0;
}
Esempio n. 14
0
int 
filep(const char *s)
{
#ifdef UNIX
  struct stat buf;
  if (stat(s,&buf)==-1)
    return FALSE;
  if (buf.st_mode & S_IFDIR) 
    return FALSE;
#endif
#ifdef WIN32
  struct _stat buf;
  if (_stat(s,&buf)==-1)
    return FALSE;
  if (buf.st_mode & S_IFDIR) 
    return FALSE;
#endif
  return TRUE;
}
Esempio n. 15
0
// TMsgCommPingReply::Pack
// Virtual method from TMessage.  Packs data into message buffer and
// sets the new message length.
void*
TMsgCommPingReply::Pack(void)
{
	WTRACE("TMsgCommPingReply::Pack");
	SetServiceType(WONMsg::CommonService);
	SetMessageType(WONMsg::CommPingReply);
	TMessage::Pack();

#ifdef WIN32
	// Build image if needed
	if (mImage.empty())
	{
		char aFileNameStr[_MAX_PATH+1];
		GetModuleFileName(NULL, aFileNameStr, _MAX_PATH+1);
		mImage = aFileNameStr;
	}

	// Fetch version if needed
	if (mVersion == 0)
	{
		struct _stat aStat;
		mVersion = (_stat(mImage.c_str(), &aStat) == -1 ? 0 : aStat.st_mtime);
	}
#endif

#if defined(macintosh) && (macintosh == 1)
#else
		// Fetch PID if needed
		if (mPID == 0)
			mPID = getpid();
#endif

	WDBG_LL("TMsgCommPingReply::Pack Appending message data");
	Append_PA_STRING(mAppName);
	Append_PA_STRING(mLogicalName);
	AppendLong(mStartTick);
	AppendLong(mVersion);
	Append_PA_STRING(mImage);
	AppendLong(mPID);
	Append_PA_STRING(mPorts);

	return GetDataPtr();
}
Esempio n. 16
0
//-----------------------------------------------------------------------------
// Name: CWaveFile::ResetFile()
// Desc: Resets the internal m_ck pointer so reading starts from the 
//       beginning of the file again 
//-----------------------------------------------------------------------------
HRESULT CPCMFile::ResetFile()
{
    if( m_bIsReadingFromMemory )
    {
        m_pbDataCur = m_pbData;
    }
    else 
    {
        if( m_hmmio == NULL )
            return CO_E_NOTINITIALIZED;

        if( m_dwFlags == WAVEFILE_READ )
        {
			// Seek to the data
            if( -1 == mmioSeek( m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC),
                            SEEK_SET ) )
                return DXTRACE_ERR( TEXT("mmioSeek"), E_FAIL );

			struct _stat buf;
			_stat(m_strFileName, &buf);
            // Search the input file for the 'data' chunk.
            m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
           	m_ck.cksize = buf.st_size;
			m_ck.fccType = 0;
			m_ck.dwDataOffset = 0;
			m_ck.dwFlags = 0;
        }
        else
        {
            // Create the 'data' chunk that holds the waveform samples.  
            m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
            m_ck.cksize = 0;

            if( 0 != mmioCreateChunk( m_hmmio, &m_ck, 0 ) ) 
                return DXTRACE_ERR( TEXT("mmioCreateChunk"), E_FAIL );

            if( 0 != mmioGetInfo( m_hmmio, &m_mmioinfoOut, 0 ) )
                return DXTRACE_ERR( TEXT("mmioGetInfo"), E_FAIL );
        }
    }
    
    return S_OK;
}
Esempio n. 17
0
static bool s_createDirectoryIfNecessary(const char * szDir)
{
	struct _stat statbuf;
	
	if (_stat(szDir,&statbuf) == 0)								// if it exists
	{
		if ( (statbuf.st_mode & _S_IFDIR) == _S_IFDIR )			// and is a directory
			return true;

		UT_DEBUGMSG(("Pathname [%s] is not a directory.\n",szDir));
		return false;
	}

	if (CreateDirectory(szDir,NULL))
		return true;

	UT_DEBUGMSG(("Could not create Directory [%s].\n",szDir));
	return false;
}
Esempio n. 18
0
static int 
filep(lua_State *L, int i)
{
  const char *s = luaL_checkstring(L, i);
#ifdef _WIN32
  struct _stat buf;
  if (_stat(s,&buf) < 0)
    return 0;
  if (buf.st_mode & S_IFDIR) 
    return 0;
#else
  struct stat buf;
  if (stat(s,&buf) < 0)
    return 0;
  if (buf.st_mode & S_IFDIR) 
    return 0;
#endif
  return 1;
}
Esempio n. 19
0
int os_file_stat(const char *path, struct os_file_stat *buf, int *pfile_errno)
{
    struct stat sb;

    if (_stat(path, &sb) == -1) {
        *pfile_errno = errno;
        buf->flags = FILE_FLAG_IS_ERROR;
        return -1;
    }

    if (sb.st_mode & S_IFDIR)
        buf->flags = FILE_FLAG_IS_DIRECTORY;
    else if (sb.st_mode & S_IFREG)
        buf->flags = FILE_FLAG_IS_PLAIN_FILE;
    else
        buf->flags = FILE_FLAG_IS_UNKNOWN;

    return 0;
}
unsigned ManagerState::GetFileSize(const char* file)
{
	struct _stat fileInfo;

	FILE* stream = fopen(file, "rb");
	if (stream != NULL)
	{
		if (_stat(file, &fileInfo)==-1)
		{
			fclose(stream);
			return 0;
		}

		fclose(stream);
		return fileInfo.st_size;
	}

	return 0;
}
Esempio n. 21
0
//打印日志函数
void WriteLog( const char* str )
{
//	return;
	char timebuf[128],datebuf[128];

	_tzset();
	_strtime( timebuf );
	_strdate( datebuf );
	char * p = datebuf;
	while(*p)
	{
		if(*p == '/')
			*p = '-';
		p++;
	}

	char szProgramName[128] = {0};
	sprintf(szProgramName , "%s.log" , "SmsSend(USMP)");
	string	strEccPath = GetSiteViewRootPath();
	char szLogFile[128];
	sprintf( szLogFile, "%s\\temp\\%s", 
		     strEccPath.c_str(), szProgramName );
	
	// 判断文件大小:在不打开文件的情况下实现
	struct _stat buf;
	if( _stat( szLogFile, &buf ) == 0 )
	{
		if( buf.st_size > 10000*1024 )
		{
			FILE *log = fopen( szLogFile, "w" );
			if( log != NULL )
				fclose( log );
		}
	}

	FILE *log = fopen( szLogFile,"a+");
	if( log != NULL )
	{
		fprintf( log, "%s \t%s\n", timebuf, str );
		fclose( log );
	}

}
Esempio n. 22
0
//-----------------------------------------------------------------------------//
// load binary animation file
//-----------------------------------------------------------------------------//
SKeyGroupLoader* CFileLoader::LoadAni_Bin( char *szFileName )
{
	// file size만큼 메모리에 담는다. (header제외)
	FILE *fp = fopen( szFileName, "rb" );
	char temp[3];
	fread( temp, sizeof(char), 3, fp );
	struct _stat buf;
	_stat( szFileName, &buf );
	int filesize = buf.st_size-3; // 64 bit (header제외)
	BYTE *pRead = new BYTE[ filesize];
	fread( pRead, 1, filesize, fp );
	fclose( fp );

	// data parsing
	s_MemLoader.ReadBin( pRead, "ANIFORM" );
	SKeyGroupLoader *pLoader = (SKeyGroupLoader*)pRead;

	return pLoader;
}
Esempio n. 23
0
bool isdir(const std::string& path)
{
	// TODO: Do we need transcode here?
#ifdef WIN32
	struct _stat s;
	_stat(fs::normalize(path).c_str(), &s);
#else
	struct stat s;
	stat(fs::normalize(path).c_str(), &s);
#endif
	// S_IFDIR: directory file.
	// S_IFCHR: character-oriented device file
	// S_IFBLK: block-oriented device file
	// S_IFREG: regular file
	// S_IFLNK: symbolic link
	// S_IFSOCK: socket
	// S_IFIFO: FIFO or pipe
	return (s.st_mode & S_IFDIR) != 0;
}
Esempio n. 24
0
/**
  *  Function: SzDateFromFileName
  *    Returns a string containing the time and date stamp on a file.
  *
  *  Arguments:
  *   sz, destination buffer
  *   szFile, path to file
  *
  *  Returns:
  *   date and time in sz
  *
  *  Error Codes:
  *   none (but leaves sz empty)
  *
  *  Comments:
  *   Assumes sz is large enough for date string.
  *
  *  History:
  *   2/92, Implemented       SteveBl
  */
void SzDateFromFileName(CHAR *sz,CHAR *szFile)
{

#ifdef RLWIN32

    HANDLE hFile;
    WCHAR szt[MAXFILENAME];
    
    _MBSTOWCS( szt,
               szFile,
               WCHARSIN( sizeof( szt)),
               ACHARSIN( lstrlenA( szFile) + 1));

    hFile = CreateFile( szt,
                        GENERIC_READ,
                        FILE_SHARE_READ,
                        NULL,
                        OPEN_EXISTING,
                        0,
                        NULL);

    if ( hFile != (HANDLE)-1 )
    {
        FILETIME ft;

        GetFileTime( hFile, NULL, NULL, &ft);
        TranslateFileTime( sz, ft);
        CloseHandle( hFile);
    }
#else //RLWIN32
    struct _stat s;
    
    if (!_stat(szFile,&s))
    {
        sprintf(sz,"%s",ctime(&s.st_atime));
        StripNewLine(sz);
    }
    else
    {
        sz[0] = 0;
    }
#endif
}
Esempio n. 25
0
const bool OTPaths::FolderExists(const OTString & strFolderPath)
{
	if (!strFolderPath.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strFolderPath" ); OT_ASSERT(false); }

	// remove trailing backslash for stat
	std::string l_strPath(strFolderPath.Get());
	l_strPath = (OTString::replace_chars(l_strPath,"\\",'/'));  // all \ to /

	//std::string l_strPath_stat = l_strPath;
	std::string l_strPath_stat("");
	
	// remove last / if it exists (for l_strPath_stat)
	if ('/' == *l_strPath.rbegin())
		l_strPath_stat = l_strPath.substr(0, l_strPath.size()-1);
	else l_strPath_stat = l_strPath;

	if ('/' == *l_strPath.rbegin())
	{

		int status=0;
#ifdef _WIN32
		struct _stat st_buf;
        memset(&st_buf, 0, sizeof(st_buf));
		char filename[4086]="";	// not sure about this buffer,
		// on windows paths cannot be longer than 4086,
		// so it should be fine... needs more research.
		strcpy_s(filename,l_strPath_stat.c_str());
		status = _stat(filename, &st_buf );
#else
		struct stat st_buf;
        memset(&st_buf, 0, sizeof(st_buf));
		status = stat (l_strPath.c_str(), &st_buf);
#endif

		if (S_ISDIR(st_buf.st_mode))
		{
			// good we have a directory.
			return true;
		}
	}
	return false;
}
Esempio n. 26
0
int CSmtpClient::Base64EncodeAttachment(CString sFileName, 
										std::string& sEncodedFileData)
{
  strconv_t strconv;
  
  int uFileSize = 0;
  BYTE* uchFileData = NULL;  
  struct _stat st;
  LPCSTR lpszFileNameA = strconv.t2a(sFileName.GetBuffer(0));

  int nResult = _stat(lpszFileNameA, &st);
  if(nResult != 0)
    return 1;  // File not found.
  
  // Allocate buffer of file size
  uFileSize = st.st_size;
  uchFileData = new BYTE[uFileSize];

  // Read file data to buffer.
  FILE* f = NULL;
#if _MSC_VER<1400
  f = fopen(lpszFileNameA, "rb");
#else
  /*errno_t err = */_tfopen_s(&f, sFileName, _T("rb"));  
#endif 

  if(!f || fread(uchFileData, uFileSize, 1, f)!=1)
  {
    delete [] uchFileData;
    uchFileData = NULL;
    return 2; // Coudln't read file data.
  }
  
  fclose(f);
    
  sEncodedFileData = base64_encode(uchFileData, uFileSize);

  delete [] uchFileData;

  // OK.
  return 0;
}
Esempio n. 27
0
/*!

  Create a new directory.

  \param dirname : Directory to create. The directory name
  is converted to the current system's format; see path().

  \exception vpIoException::invalidDirectoryName : The \e dirname is invalid.

  \exception vpIoException::cantCreateDirectory : If the directory cannot be
  created.

  \sa makeDirectory(const std::string &)
*/
void
vpIoTools::makeDirectory(const  char *dirname )
{
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
  struct stat stbuf;
#elif defined(_WIN32)
  struct _stat stbuf;
#endif

  if ( dirname == NULL || dirname[0] == '\0' ) {
    vpERROR_TRACE( "invalid directory name\n");
    throw(vpIoException(vpIoException::invalidDirectoryName,
			"invalid directory name")) ;
  }

  std::string _dirname = path(dirname);

#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
  if ( stat( _dirname.c_str(), &stbuf ) != 0 )
#elif defined(_WIN32)
  if ( _stat( _dirname.c_str(), &stbuf ) != 0 )
#endif
  {
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
    if ( mkdir( _dirname.c_str(), (mode_t)0755 ) != 0 )
#elif defined(_WIN32)
    if ( _mkdir( _dirname.c_str()) != 0 )
#endif
    {
      vpERROR_TRACE("unable to create directory '%s'\n",  dirname );
      throw(vpIoException(vpIoException::cantCreateDirectory,
			  "unable to create directory")) ;
    }
    vpDEBUG_TRACE(2,"has created directory '%s'\n", dirname );
  }

  if ( checkDirectory( dirname ) == false) {
    vpERROR_TRACE("unable to create directory '%s'\n",  dirname );
    throw(vpIoException(vpIoException::cantCreateDirectory,
			"unable to create directory")) ;
  }
}
Esempio n. 28
0
/* _al_file_time:
 *  Returns the timestamp of the specified file.
 */
time_t _al_file_time(AL_CONST char *filename)
{
   struct _stat s;
   char tmp[1024];

   if (get_filename_encoding() != U_UNICODE) {
      if (_stat(uconvert(filename, U_CURRENT, tmp, U_ASCII, sizeof(tmp)), &s) != 0) {
         *allegro_errno = errno;
         return 0;
      }
   }
   else {
      if (_wstat((wchar_t*)uconvert(filename, U_CURRENT, tmp, U_UNICODE, sizeof(tmp)), &s) != 0) {
         *allegro_errno = errno;
         return 0;
      }
   }

   return s.st_mtime;
}
Esempio n. 29
0
void CVCProjConvert::FindFileCaseInsensitive( char *fileName, int fileNameSize )
{
	char filePath[ MAX_PATH ];

	Q_snprintf( filePath, sizeof(filePath), "%s/%s", m_BaseDir.String(), fileName ); 

	struct _stat buf;
	if ( _stat( filePath, &buf ) == 0)
	{
		return; // found the filename directly
	}

#ifdef _LINUX
	const char *realName = findFileInDirCaseInsensitive( filePath );
	if ( realName )
	{
		Q_strncpy( fileName, realName+strlen(m_BaseDir.String())+1, fileNameSize );
	}
#endif
}
Esempio n. 30
0
uint FileStream::getLength() 
{
	if (isOpen())
	{
		uint curPos = getPosition();
		seekToEnd();
		uint len = getPosition();
		seek(curPos, SEEK_SET);
		return len;
        
		//return _filelength(_fileno(m_stream));
	}

	if (m_path.empty())
		return 0;

	struct _stat statbuf;
	_stat(m_path.c_str(), &statbuf);
	return statbuf.st_size;
}