[
板情報
|
カテゴリランキング
]
したらばTOP
■掲示板に戻る■
全部
1-100
最新50
|
メール
|
1-
101-
201-
301-
401-
501-
601-
701-
801-
901-
1001-
1101-
1201-
1301-
1401-
1501-
1601-
1701-
1801-
1901-
2001-
2101-
2201-
2301-
2401-
2501-
2601-
2701-
2801-
2901-
3001-
3101-
3201-
3301-
3401-
3501-
3601-
3701-
3801-
3901-
4001-
4101-
4201-
4301-
4401-
4501-
4601-
4701-
4801-
4901-
5001-
5101-
5201-
5301-
5401-
この機能を使うにはJavaScriptを有効にしてください
|
管理人の独り言(プログラミング関連)
3899
:
ACUVE★
:2012/06/18(月) 00:34:20
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <boost/format.hpp>
#include <boost/optional.hpp>
#include "scope_exit.hpp"
#if defined(UNICODE) || defined(_UNICODE)
typedef std::wstring tstring;
typedef std::wostringstream tstringstream;
typedef boost::wformat tformat;
boost::optional<tstring> a2t(std::string const str){
int len = MultiByteToWideChar(CP_THREAD_ACP, MB_PRECOMPOSED, str.c_str(), -1, NULL, 0);
if(!len) return {};
wchar_t *wc = new(std::nothrow) wchar_t[len];
if(!wc) return {};
scope_exit{delete[] wc;};
if(!MultiByteToWideChar(CP_THREAD_ACP, MB_PRECOMPOSED, str.c_str(), -1, wc, len)) return {};
return tstring(wc);
}
#else
typedef std::string tstring;
typedef std::ostringstream tstringstream;
typedef boost::format tformat;
#endif
int main(int argc, char **argv){
int max = 1;
tstring fm = TEXT("pad%1$04d.vhd");
if(argc >= 2){
boost::optional<tstring> b = a2t(argv[1]);
if(b && *b != TEXT("*")){
fm = *b;
}
}
if(argc >= 3){
max = std::atoi(argv[2]);
}
for(int i = 0; i < max; ++i){
tstringstream oss;
oss << tformat(fm) % i << std::flush;
HANDLE h = CreateFile(oss.str().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
DWORD dw;
DeviceIoControl(h, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL);
LONGLONG size = 1024LL * 1024 * 1024 * 500;
LONG lLo = *((LONG*)&size);
LONG lHi = *((LONG*)&size + 1);
SetFilePointer(h, lLo, &lHi, FILE_BEGIN);
SetEndOfFile(h);
CloseHandle(h);
}
}
新着レスの表示
名前:
E-mail
(省略可)
:
※書き込む際の注意事項は
こちら
※画像アップローダーは
こちら
(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)
スマートフォン版
掲示板管理者へ連絡
無料レンタル掲示板