⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file_util.cpp

📁 一个开源的Flash 播放器,可以在Windows/Linux 上运行
💻 CPP
字号:
// file_util.cpp	-- Thatcher Ulrich <tu@tulrich.com> 2005

// This source code has been donated to the Public Domain.  Do
// whatever you want with it.

// A file class that can be customized with callbacks.


#include "base/file_util.h"
#include "base/utility.h"
#include <string.h>


static const char* reverse_scan(const char* begin, const char* end, char c)
// Scans in reverse, from *(end-1) through *begin, until it finds a
// character matching c.  If none is found, returns end, else returns
// a pointer to the char.
{
	assert(begin <= end);
	
	const char* p = end;
	while (p > begin) {
		p--;
		if (*p == c) {
			return p;
		}
	}

	return end;
}


const char* file_util::get_extension(const char* path)
{
	int len = strlen(path);
	const char* last_dot = reverse_scan(path, path + len, '.');
	const char* last_slash = reverse_scan(last_dot, path + len, '/');

	if (last_dot[0] && last_slash[0] == 0) {
		return last_dot + 1;
	}

	// No apparent file extension, return an empty string.
	return path + len;
}



// Local Variables:
// mode: C++
// c-basic-offset: 8 
// tab-width: 8
// indent-tabs-mode: t
// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -