Exemplo n.º 1
0
bool Navigator::NavLine::operator<(const NavLine& b) const
{
	String p1 = GetSourceFilePath(file);
	String p2 = GetSourceFilePath(b.file);
	return CombineCompare/*(!impl, !b.impl)*/
	                     (GetFileExt(p2), GetFileExt(p1)) // .h > .c
	                     (GetFileName(p1), GetFileName(p2))
	                     (p1, p2)
	                     (line, b.line) < 0;
}
Exemplo n.º 2
0
int CDLNAManager::AddFileItem(wstring parentObjectID, wstring filePath, wstring& objectID)
{
	wstring fileName;
	wstring fileExt;

	GetFileName(filePath, fileName);
	GetFileExt(filePath, fileExt);

	map<wstring, DLNA_PROTOCOL_INFO>::iterator itrInfo;
	itrInfo = protocolInfo.supportList.find(fileExt);
	if( itrInfo == protocolInfo.supportList.end() ){
		return ERR_FALSE;
	}

	DLNA_DMS_CONTENT_META_INFO itemInfo;
	itemInfo.title = fileName;
	itemInfo.filePath = filePath;
	itemInfo.upnpClass = itrInfo->second.upnpClass;
	itemInfo.mimeType = itrInfo->second.mimeType;
	itemInfo.protocolInfo = itrInfo->second.info;

	HANDLE hFile = CreateFile( filePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
	if( hFile == INVALID_HANDLE_VALUE ){
		return 0;
	}
	DWORD sizeH = 0;
	DWORD sizeL = GetFileSize( hFile, &sizeH );
	__int64 fileSize = 0;
	itemInfo.fileSize = ((__int64)sizeH)<<32 | sizeL;
	CloseHandle(hFile);

	dms.AddContent(parentObjectID, &itemInfo, objectID);

	return NO_ERR;
}
Exemplo n.º 3
0
bool FindFile::IsSymLink() const
{
	String name = GetName();
	if(GetFileExt(name) != ".lnk")
		return false;
	return sGetSymLinkPath0(AppendFileName(path, name), NULL);
}
Exemplo n.º 4
0
int CIOSFileList::InsertItem(int nItem, LPCTSTR lpszItem, int nImage)
{
	int imageIndex = nImage;
	if(nImage == -1 || nImage == -2)
	{
		std::wstring ext;
		if (nImage == -1)
		{
			ext = GetFileExt(lpszItem);
		}
		else if (nImage == -2)
		{
			ext = _T("*.Lnk");
		}

		if(m_extToImageIndex.count(ext))
		{
			imageIndex = m_extToImageIndex[ext];
		}
		else
		{
			SHFILEINFO sfi;
			SHGetFileInfo(ext.c_str(), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_USEFILEATTRIBUTES|SHGFI_ICON);
			imageIndex = m_imageList.Add(sfi.hIcon);
			m_extToImageIndex[ext] = imageIndex;
		}
	}

	return CListCtrl::InsertItem(nItem, lpszItem, imageIndex);
}
Exemplo n.º 5
0
int CFileMng::ReadExtFilesFromPack( char *ext , packsearch_t **searchList )
{
	int				numFound;
	char			*extention;

	*searchList		=	m_packSearch;
	numFound		=	0;

	packfilemap::iterator i = m_fileMap.begin();

    while( i != m_fileMap.end() )
	{
        packfileinfo_t	*pi		=	(*i ++).second;

		if( pi == NULL )
			continue;
		
		extention				=	GetFileExt( pi->fi.name );

		if( !extention ) continue;	
		if( !stricmp( extention , ext ) ) 
		{
			m_packSearch[numFound].pack		=	pi->packidx;
			m_packSearch[numFound].entry	=	pi->idx_inpack;
			m_packSearch[numFound].size		=	pi->fi.size;
			m_packSearch[numFound].date		=	pi->fi.date;
			
			strcpy( m_packSearch[numFound].name , pi->fi.name );

			numFound	++;
		}
	}

	return numFound;
}
Exemplo n.º 6
0
BOOL CFileSaveAsGraphicDlg::OnFileNameOK ()
{
	UpdateData(TRUE);

	ASSERT (m_ofn.nFilterIndex > 0);
	m_nGraphicIndex = m_ofn.nFilterIndex;

	CString strFolder = GetFolderPath();
	CString strFile = GetFileName();
	CString strExt = GetFileExt();
	if (strFolder.GetLength() + strFile.GetLength() + strExt.GetLength() >= (_MAX_PATH - 10))
	{
		AfxMessageBox(IDS_PATH_TOO_LONG);

		CEdit* pEdit = (CEdit*)GetParent()->GetDlgItem(edt1);
		if (pEdit)
		{
			pEdit->SetFocus();
			pEdit->SetSel(0, -1);
		}

		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 7
0
TCHAR* YMSPlugin::MakeFileName(LPCTSTR DestPath, LPCTSTR fname,int)
{
    TCHAR* fmt;
    switch(DestPath[_tcslen(DestPath)-1])
    {
        case '\\': case'/': case':':
            fmt = _T("%s%s%s"); break;
        default: fmt = _T("%s\\%s%s");
    }

    TCHAR name[MAX_PATH];
    bool bTwoDots = false;
    if(!_tcscmp(fname, _T("..")))
    {
        // make name out of parent name
        TCHAR* p = _tcsrchr(CurDir, '\\');
        if(!p) p = CurDir;
        if(!*p) p = _T("(root)");
        fname = p;
        bTwoDots = true;
    }
    bool bAllDots = true;
    TCHAR* maxName = name + MAX_PATH-1 - _tcslen(GetFileExt()) - _tcslen(DestPath)-2;
    _TUCHAR* q = (_TUCHAR*)name;
    for(_TUCHAR*p = (_TUCHAR*)fname; *p; p++)
    {
        if(_tcschr(invalid_chars, *p) || *p<' ')
	{
            *q++ = '#'; *q++ = hexdigit(*p>>4); *q++ = hexdigit(*p&15);
        }
        else
Exemplo n.º 8
0
Image GetFileIcon(const char *path, bool dir, bool force, bool large, bool quick = false)
{
	FileIconMaker m;
	String ext = GetFileExt(path);
	m.exe = false;
	m.dir = false;
	m.file = path;
	m.large = large;
	if(force)
		m.exe = true;
	else
	if(dir) {
		m.dir = true;
		m.exe = true;
	}
	else
	if(ext == ".exe")
		m.exe = true;
	else
		m.file = "x." + ext;
	if(quick) {
		m.exe = false;
		m.file = "x." + ext;
	}
	return MakeImage(m);
}
Exemplo n.º 9
0
TCHAR* SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, TCHAR* pszFilename, TCHAR* pszExt, int flag) {
	int ret=0;
	TCHAR* pszFile = NULL;
	TCHAR* FileExt = GetFileExt(pszFilename);
	if(!FileExt) {
		if(!pszExt) return NULL;
		mir_tcsadd(pszFile, pszFilename);
		mir_tcsadd(pszFile, _T("."));
		mir_tcsadd(pszFile, pszExt);
	}
	else {
		mir_tcsadd(pszFile, pszFilename);
	}

	if(fif==FIF_UNKNOWN) {
		fif = FIP->FI_GetFIFFromFilenameU(pszFile);
	}

	ret = FIP->FI_SaveU(fif, dib, pszFile, flag);


	mir_free(FileExt);

	if(ret) return pszFile;
	mir_free(pszFile);
	return NULL;
}
Exemplo n.º 10
0
int CFileFilter::DoPromptFilePath(CString &fpath, BOOL bOpen)
{
	int ii;
	CString fdir, ftitle, fltr;
	// get dir from fpath or profile
	if(!GetFileDir(fpath, fdir))
	{
		CString flast= 
			::AfxGetApp()->GetProfileString("Last File", mDlgName, NULL);
		GetFileDir(flast, fdir);
	}
	if(mCurrID<0)
		mCurrID= AfxGetApp()->GetProfileInt("Last Filter", mDlgName, 0);

	// setup filters
	for(ii=0; ii<mFilterSize; ii++)
		fltr += mFilters[ii];
	
	DWORD dwFlags;
	if(bOpen)	// loading file: no init name
	{
		dwFlags= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
	}
	else		// storing file: init name is fpath's title
	{
		dwFlags= OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
		GetFileTitle(fpath, ftitle);
	}

	CFileDialog fdlg(bOpen, NULL, ftitle, dwFlags, fltr, NULL);
	fdlg.m_ofn.lpstrInitialDir= fdir;
	fdlg.m_ofn.nFilterIndex= mCurrID+1;
	fdlg.m_ofn.lpstrTitle= mDlgName;

	if(fdlg.DoModal() == IDOK)
	{
		fpath= fdlg.GetPathName();
		GetFileDir(fpath, fdir);
		mCurrID= fdlg.m_ofn.nFilterIndex-1;
		CString fext;
		// no extension given, make one up
		if(!GetFileExt(fpath, fext) && mCurrID >= 0)
		{
			fext= GetFilterExt(mCurrID);
			// unless the filter's extension is invalid
			if(fext.IsEmpty() || fext.FindOneOf("*?") >= 0)
			{
				fpath.Empty();
				return FF_BAD;
			}
			fpath += "." + fext;
		}	

		::AfxGetApp()->WriteProfileString("Last File", mDlgName, fpath);
		::AfxGetApp()->WriteProfileInt("Last Filter", mDlgName, mCurrID);
		return GetFilterID(fext, true);
	}
	fpath.Empty();
	return FF_CANCEL;
}
Exemplo n.º 11
0
void GrabScreen::ButSnap_Push() {
/*	program->Minimize();
	
	TopWindow win;
	Button b;
	b.SetLabel("CLOSE");
	b <<= win.Breaker();
	StaticImage desktop;
	desktop.Set(Snap_Desktop());
	win.Add(desktop.SizePos());
	win.Add(b.LeftPos(10, 100).TopPos(10, 30));
	
	win.FullScreen().Run();
	
	program->Overlap();
*/	
	String fileName = ~editFileNameSnap;
	FileDelete(fileName);
	
	String ext = GetFileExt(fileName);
	
	if (ext == ".png") {
		PNGEncoder encoder;
		if (!encoder.SaveFile(fileName, canvasImage))
			Exclamation(Format(t_("Impossible to save %s"), fileName));
	} else if (ext == ".jpg") {	
		JPGEncoder encoder(90);
		if (!encoder.SaveFile(fileName, canvasImage))
			Exclamation(Format(t_("Impossible to save %s"), fileName));
	} else
		Exclamation(Format(t_("File format \"%s\" not found"), ext));
}
Exemplo n.º 12
0
cBitmap2ButtonEx::cBitmap2ButtonEx(
	wxWindow *parent,
	wxWindowID id,
	const wxString& fileName,
	const wxPoint& pos,
	const wxSize& size,
	long style,
	BUTTON2_TYPE::TYPE buttonImageType
	)
	: cBitmap3ButtonEx(parent, id, pos, size, style)
	, m_buttonImgType(buttonImageType)
{
	int w = size.GetWidth();
	int h = size.GetHeight();
	if (!fileName.IsEmpty())
	{
		wxImage img(fileName + _("_0") + GetFileExt());
		w = img.GetWidth();
		h = img.GetHeight();
	}

	SetMinSize(wxSize(w, h));

	// 버튼이미지 업데이트
	SetButton2Bitmap(fileName);
}
Exemplo n.º 13
0
int PackFileSearchFilesExt( packfile_t *pf , char *ext , int pack , packsearch_t *list )
{
	 
	if	(	! pf->uf	)
		return	0;

	unsigned long i;
	int numFound;
	char *extention;

	numFound = 0;
	for( i = 0 ; i < pf->gi.number_entry ; i++ )
	{
		extention = GetFileExt( pf->fi[i].name );
		if( !extention ) continue;		

		if( !stricmp( extention , ext ) ) 
		{
			list[ numFound ].pack  = pack;
			list[ numFound ].entry = i;
			list[ numFound ].size  = pf->fi[i].size;
			list[ numFound ].date  = pf->fi[i].date;
			strcpy( list[ numFound++ ].name , pf->fi[i].name );
		}
	}

	return numFound;
}
Exemplo n.º 14
0
std::wstring StripExtensionFromPath(const std::wstring& path)
{
	UIETWASSERT(path.size() > 0);
	const std::wstring ext = GetFileExt(path);
	UIETWASSERT(path.size() >= ext.size());
	return path.substr(0, path.size() - ext.size());
}
Exemplo n.º 15
0
void SoundBuffer::Init( const char * a_file_name )
{
	ASSERT(a_file_name);

	// buffer id
	alGenBuffers( 1, &m_id );
	ASSERT( m_id != 0 );
	ASSERT( alIsBuffer(m_id) );
	SoundManager::Ref().CheckError();

	// load file based on extension
	const char * ext = GetFileExt( a_file_name );
	if ( strcmp( ext, "wav" ) == 0 )
		InitWave(a_file_name);
	else if ( strcmp( ext, "ogg" ) == 0 )
		InitOgg(a_file_name);
	else
		ERROR_MSG("Cannot load sound '%s': unrecognized file extension '%s'", a_file_name, ext );

	// TEMPFIX: basically, if we turn off vorbis, GetProperties will crash..
	#if defined(USE_VORBIS)
	GetBufferProperties();
	#endif

	SoundManager::Ref().CheckError();
}
Exemplo n.º 16
0
	void ListFileInDirection(const char * path, const char * extension, const std::function<void(const char *, const char *)> &f) {
#ifdef WIN32
		WIN32_FIND_DATA finder;

		char tmp[512] = { 0 };
		SafeSprintf(tmp, sizeof(tmp), "%s/*.*", path);

		HANDLE handle = FindFirstFile(path, &finder);
		if (INVALID_HANDLE_VALUE == handle)
			return;

		while (FindNextFile(handle, &finder)) {
			if (strcmp(finder.cFileName, ".") == 0 || strcmp(finder.cFileName, "..") == 0)
				continue;

			SafeSprintf(tmp, sizeof(tmp), "%s/%s", path, finder.cFileName);
			if (finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				ListFileInDirection(tmp, extension, f);
			else {
				if (0 == strcmp(extension, PathFindExtension(finder.cFileName))) {
					PathRemoveExtension(finder.cFileName);
					f(finder.cFileName, tmp);
				}
			}
		}
#else
		DIR * dp = opendir(path);
		if (dp == nullptr)
			return;

		struct dirent * dirp;
		while ((dirp = readdir(dp)) != nullptr) {
			if (dirp->d_name[0] == '.')
				continue;

			char tmp[256] = { 0 };
			SafeSprintf(tmp, sizeof(tmp), "%s/%s", path, dirp->d_name);

			struct stat st;
			if (stat(tmp, &st) == -1)
				continue;

			if (S_ISDIR(st.st_mode))
				ListFileInDirection(tmp, extension, f);
			else {
				if (0 == strcmp(extension, GetFileExt(dirp->d_name))) {
					char name[256];
					SafeSprintf(name, sizeof(name), "%s", dirp->d_name);
					char * dot = strrchr(name, '.');
					if (dot != nullptr)
						*dot = 0;
					f(name, tmp);
				}
			}
		}
#endif
	}
Exemplo n.º 17
0
NAMESPACE_UPP

#define LTIMING(x)  // RTIMING(x)
#define LLOG(x)     // DLOG(x)

bool IsCPPFile(const String& path)
{
	return findarg(ToLower(GetFileExt(path)) , ".c", ".cpp", ".cc" , ".cxx", ".icpp") >= 0;
}
Exemplo n.º 18
0
std::wstring CrackFilePart(const std::wstring& path)
{
	const std::wstring filePart = GetFilePart(path);
	const std::wstring extension = GetFileExt(filePart);
	UIETWASSERT(filePart.size() >= extension.size());
	if (!extension.empty())
		return filePart.substr(0, filePart.size() - extension.size());
	return filePart;
}
Exemplo n.º 19
0
void	CHtmlFile::sendfile(CString strFilePath)
{
	LOG_DEBUG(_T("ファイルを送信 : %s"), strFilePath);

	CString strArg;
	int n = strFilePath.Find(_T('?'));
	if (n != -1) {
		strArg = strFilePath.Mid(n + 1);
		strFilePath.Delete(n + 1);
	}

	enum { HeaderSize = 1012 };
	m_buf.reserve(HeaderSize);

	CString strExt = GetFileExt(strFilePath);
	strExt.MakeLower();
	try {
		if (strExt == _T("htm") || strExt == _T("html")) {
			_writeHeader(MIME_HTML);
			_writeTemplate(strFilePath);

		} else if (strExt == _T("css")) {
			_writeHeader(MIME_CSS);
			_writeRawFile(strFilePath);

		} else if (strExt == _T("js")) {
			_writeHeader("application/x-javascript");
			_writeRawFile(strFilePath);

		} else if (strExt == _T("jpg")) {
			_writeHeader(MIME_JPEG);
			_writeRawFile(strFilePath);

		} else if (strExt == _T("gif")) {
			_writeHeader(MIME_GIF);
			_writeRawFile(strFilePath);

		} else if (strExt == _T("png")) {
			_writeHeader(MIME_PNG);
			_writeRawFile(strFilePath);

		} else {
			_writeHeader(MIME_TEXT);
			_writeRawFile(strFilePath);
		}
	} catch (StreamException& e) {	// 404
		LOG_ERROR("%s : 404エラーを送信", e.msg);
		m_buf.clear();
		_writeLine(HTTP_SC_NOTFOUND);
		_writeLine("%s %s", HTTP_HS_SERVER, PCX_AGENT);
		_writeLine("%s %s", HTTP_HS_CONNECTION, "close");
		_writeLine("%s %s", HTTP_HS_CONTENT, MIME_HTML);
	}

	m_psock->send(m_buf.data(), m_buf.size());
}
Exemplo n.º 20
0
bool Texture::Load(const std::string& filename)
{
    unsigned int w = 0;
    unsigned int h = 0;
    unsigned char* data = 0;
    unsigned int bpp = 3; // bytes per pixel

#ifdef AMJU_USE_SDL_IMG

    SDL_Surface* surf = IMG_Load(filename.c_str());
    if (!surf)
    {
        ReportError("Failed to load texture " + filename);
        return false;
    }
    w = surf->w;
    h = surf->h;
    data = (unsigned char*)surf->pixels;
    bpp = surf->format->BytesPerPixel;

#else

    std::string ext = ToLower(GetFileExt(filename));
    if (ext == "bmp")
    {
        data = LoadDIBitmap(filename.c_str(), &w, &h);
    }
    else if (ext == "png")
    {
        data = LoadPng(filename.c_str(), &w, &h, &bpp);
        // TODO I think bmps are upside down, but the rest of the code compensates.. sigh
        FlipBmp(data, w, h, bpp);
    }

    if (!data)
    {
        ReportError("Failed to load texture " + filename);
        return false;
    }

#endif

    Create(data, w, h, bpp);

#ifdef AMJU_USE_SDL_IMAGE
    SDL_FreeSurface(surf);
#else
    delete [] data;
#endif

#ifdef _DEBUG
    m_name = StripPath(filename);
#endif

    return true;
}
Exemplo n.º 21
0
NewPackageFileWindow::NewPackageFileWindow()
{
	CtrlLayoutOKCancel(*this, "New package file");

	type.SetLineCy(max(Zy(16), Draw::GetStdFontCy()));
	type.SetDropLines(20);
	Type("cpp", "C++ source file");
	Type("h", "C++ header file");
	type.AddSeparator();
	Type("lay", "Layout file (dialog templates)");
	Type("iml", "Image file (icons)");
	Type("icpp", "Initialization C++ source file");
	Type("usc", "Escape script file (scripting TheIDE)");
	Type("witz", "Skylark template file (web framework files)");
	Type("qtf", "U++ rich text file");
	type.AddSeparator();
	Type("json", "JSON file");
	Type("xml", "XML file");
	Type("html", "HTML file");
	Type("css", "CSS file");
	type.AddSeparator();
	Type("sch", "SQL schema file");
	Type("ddl", "SQL DDL script file");
	Type("sql", "SQL script file");
	type.AddSeparator();
	Type("java", "Java");
	Type("js", "JavaScript");
	Type("py", "Python");
	type.AddSeparator();
	Type("", "Other");
	
	name << [=] {
		String ext = GetFileExt(~~name);
		if(ext.GetCount()) {
			ext = ext.Mid(1);
			type <<= type.HasKey(ext) ? ext : Null;
		}
		Sync();
	};
	name <<= ".cpp";
	
	type <<= "cpp";
	
	type << [=] {
		String ext = ~type;
		if(ext.GetCount()) {
			String h = ~name;
			name <<= ForceExt(h, "." + ext);
			int q = GetFileTitle(h).GetCount();
			name.SetSelection(q, q);
		}
		Sync();
	};
	
	Sync();
}
Exemplo n.º 22
0
void Ide::BuildAndExecute()
{
	if(Build()) {
		String targetExt = GetFileExt(target);
		if(targetExt == ".apk")
			ExecuteApk();
		else
			ExecuteBinary();
	}
}
Exemplo n.º 23
0
std::wstring CrackFilePart(const std::wstring& path)
{
	std::wstring filePart = GetFilePart(path);
	const std::wstring extension = GetFileExt(filePart);
	if (!extension.empty())
	{
		filePart = filePart.substr(0, filePart.size() - extension.size());
	}

	return filePart;
}
Exemplo n.º 24
0
xpr_bool_t ProgramAss::getItemFromPath(const xpr_tchar_t *aPath, xpr_uint_t aType, ProgramAssDeque &aProgramAssDeque)
{
    if (XPR_IS_NULL(aPath))
        return -1;

    const xpr_tchar_t *sExt = GetFileExt(aPath);
    if (XPR_IS_NULL(sExt))
        return -1;

    return getItemFromExt(sExt, aType, aProgramAssDeque);
}
Exemplo n.º 25
0
xpr_size_t ProgramAss::indexFromPath(const xpr_tchar_t *aPath, xpr_uint_t aType)
{
    if (XPR_IS_NULL(aPath))
        return -1;

    const xpr_tchar_t *sExt = GetFileExt(aPath);
    if (XPR_IS_NULL(sExt))
        return -1;

    return indexFromExt(sExt, aType);
}
Exemplo n.º 26
0
/*bool ReadSetting(LPTSTR szSettingName,int* Value,int DefaultValue,LPTSTR szString,LPTSTR szDefString)
{
	TCHAR szFileName[256],szPath[256];
	GetModuleFileName(0,szFileName,1023);
   ExtractFilePath(szFileName,szPath);
   wsprintf(szFileName,_T("%simgupload.ini"),szPath);



	TCHAR szBuffer1[128],szBuffer2[128];
	lstrcpy(szBuffer2,GetFileExt(szSettingName));
	GetOnlyFileName(szSettingName,szBuffer1);
	if(!szString)
	*Value = GetPrivateProfileInt(szBuffer1,szBuffer2, DefaultValue, szFileName);
	else
	 GetPrivateProfileString(szBuffer1,szBuffer2, szDefString,szString,256, szFileName);
	
	return true;
}

bool WriteSetting(LPCTSTR szSettingName,int Value,LPCTSTR szString)
{
	TCHAR szFileName[256],szPath[256];
	GetModuleFileName(0,szFileName,1023);
   ExtractFilePath(szFileName,szPath);
   wsprintf(szFileName,_T("%simgupload.ini"),szPath);

	TCHAR szBuffer1[128],szBuffer2[128];
	TCHAR szBuffer3[256];
	
	lstrcpy(szBuffer2,GetFileExt(szSettingName));
	GetOnlyFileName(szSettingName,szBuffer1);
	if(!szString)
	{
		wsprintf(szBuffer3,_T("%d"),Value);
		WritePrivateProfileString(szBuffer1,szBuffer2, szBuffer3, szFileName);
	}
	else
		
	WritePrivateProfileString(szBuffer1,szBuffer2, szString, szFileName);
	
	return true;
}
*/
int GetSavingFormat(LPCTSTR szFileName)
{
	if(!szFileName) return -1;
	LPCTSTR FileType = GetFileExt(szFileName);
	if(IsStrInList(FileType,_T("jpg\0jpeg\0\0")))
		return 0;
	else if(IsStrInList(FileType,_T("png\0\0")))
		return 1;
	else if(IsStrInList(FileType,_T("gif\0\0")))
		return 2;
	else return 0;
}
Exemplo n.º 27
0
void WorkspaceWork::LoadActualPackage()
{
	Time utime = FileGetTime(ConfigFile("version"));
	filelist.Clear();
	fileindex.Clear();
	bool open = true;
	Time tm = GetSysTime();
	for(int i = 0; i < actual.file.GetCount(); i++) {
		Package::File& f = actual.file[i];
		if(f.separator) {
			open = closed.Find(Sepfo(actualpackage, f)) < 0;
			filelist.Add(f, open ? IdeImg::SeparatorClose() : IdeImg::SeparatorOpen(),
			             ListFont().Bold(), open ? SColorMark : SColorText, true, 0, Null);
			fileindex.Add(i);
		}
		else
		if(open) {
			Color uln = Null;
			String p = SourcePath(GetActivePackage(), f);
			if(showtime) {
				FindFile ff(p);
				if(ff) {
					Time ftm = Time(ff.GetLastWriteTime());
					if(ftm > utime) {
						int64 t = tm - ftm;
						if(t < 24 * 3600)
							uln = SColorMark;
						else
						if(t < 32 * 24 * 3600)
							uln = SColorDisabled;
					}
				}
			}
			Image m = IdeFileImage(f, f.optimize_speed, false, f.pch);
			if(GetFileExt(p) == ".tpp" && IsFolder(p)) {
				if(FileExists(AppendFileName(p, "all.i")))
					m = TopicImg::IGroup();
				else
					m = TopicImg::Group();
			}
		#ifdef PLATFORM_WIN32
			p = ToLower(p);
		#endif
			if(errorfiles.Find(p) >= 0) {
				m = ImageOverRed(m);
				uln = LtRed;
			}
			filelist.Add(f, m, ListFont(), SColorText, false, 0,
			             Null, SColorMark, Null, Null, Null, uln);
			fileindex.Add(i);
		}
	}
}
Exemplo n.º 28
0
void WorkspaceWork::RenameFile()
{
	if(!filelist.IsCursor()) return;
	String n = GetActiveFileName();
	int i = filelist.GetCursor();
	if(i < 0 || i >= fileindex.GetCount())
		return;
	int ii = fileindex[i];
	WithEditStringLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, "Rename file");
	dlg.lbl = "New name";
	dlg.text <<= n;
	dlg.Open();
	dlg.text.SetFocus();
	int l = int(GetFileNamePos(n) - ~n);
	int h = int(GetFileExtPos(n) - ~n);
	if(l >= h)
		l = 0;
	dlg.text.SetSelection(l, h);
	if(dlg.Run() != IDOK)
		return;
	n = ~dlg.text;
	String spath = GetActiveFilePath();
	String dpath = SourcePath(GetActivePackage(), n);
	if(!filelist[i].isdir && GetFileLength(spath) >= 0) {
		if(!::MoveFile(spath, dpath)) {
			Exclamation("Failed to rename the file.&&" + GetErrorMessage(GetLastError()));
			return;
		}
	}
	FileRename(dpath);
	int s = filelist.GetSbPos();
	(String &)actual.file[ii] = n;
	SaveLoadPackage(false);
	filelist.SetSbPos(s);
	filelist.SetCursor(i);
	if(GetFileExt(spath) == ".iml" || GetFileExt(dpath) == ".iml")
		SyncWorkspace();
}
Exemplo n.º 29
0
OJString GetFileName(const OJString &path)
{
    OJString res(GetFullFileName(path));

    if (!res.empty())
    {
        OJString ext(GetFileExt(path));

        if (!ext.empty())
            res = res.substr(0, res.size() - ext.size());
    }

    return res;
}
Exemplo n.º 30
0
void Ide::Statistics()
{
	Vector< ArrayMap<String, FileStat> > stat;
	Progress pi;
	const Workspace& wspc = IdeWorkspace();
	pi.SetTotal(wspc.GetCount());
	Date now = GetSysDate();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pk = wspc.GetPackage(i);
		String n = wspc[i];
		pi.SetText(n);
		if(pi.StepCanceled()) return;
		ArrayMap<String, FileStat>& pfs = stat.Add();
		for(int i = 0; i < pk.GetCount(); i++)
			if(!pk[i].separator) {
				String file = SourcePath(n, pk[i]);
				if(FileExists(file)) {
					FileStat& fs = pfs.GetAdd(GetFileExt(file));
					int d = minmax(now - FileGetTime(file), 0, 9999);
					fs.oldest = max(d, fs.oldest);
					fs.newest = min(d, fs.newest);
					String data = LoadFile(file);
					for(const char *s = data; *s; s++)
						if(*s == '\n')
							fs.lines++;
					fs.len += data.GetCount();
					fs.days += d;
					fs.count++;
				}
			}
	}
	String qtf = "[1 ";
	ArrayMap<String, FileStat> all;
	String tab = "{{45:20:25:20:35:30:30:30:30@L [* ";
	String hdr = "]:: [= Files:: Lines:: - avg.:: Length:: - avg.:: Oldest:: Newest:: Avg. age]";
	for(int i = 0; i < wspc.GetCount(); i++) {
		qtf << tab << DeQtf(wspc[i]) << hdr;
		sPut(qtf, stat[i], all);
	}

	qtf << tab << "All packages" << hdr;
	sPut(qtf, all, all);

	WithStatLayout<TopWindow> dlg;
	CtrlLayoutOK(dlg, "Statistics");
	dlg.stat = qtf;
	dlg.Sizeable().Zoomable();
	dlg.Run();
}