예제 #1
0
	/// コンストラクタ
	SQFileInfo(const SQChar *filename, bool binary) : is(NULL), buffer(NULL), size(0), readed(0), binary(binary) {
		is = TVPCreateIStream(filename, TJS_BS_READ);
		if (is) {
			if (binary) {
				STATSTG stat;
				is->Stat(&stat, STATFLAG_NONAME);
				size = (ULONG)stat.cbSize.QuadPart;
				buffer = new char[size];
			} else {
				DWORD len;
				unsigned short us = 0;
				is->Read(&us, 2, &len);
				if (us == SQ_BYTECODE_STREAM_TAG) { //BYTECODE
					LARGE_INTEGER move = {0};
					is->Seek(move,STREAM_SEEK_SET,NULL);
					STATSTG stat;
					is->Stat(&stat, STATFLAG_NONAME);
					size = (ULONG)stat.cbSize.QuadPart;
					buffer = new char[size];
				} else {
					is->Release();
					is = NULL;
					ttstr data;
					iTJSTextReadStream *rs = TVPCreateTextStreamForRead(filename, L"");
					rs->Read(data, 0);
					rs->Destruct();
					readed = size = data.length() * sizeof tjs_char + 2;
					buffer = new char [size];
					memcpy(buffer, "\xFF\xFE", 2); // Little Endian BOM
					memcpy(buffer+2, (void*)data.c_str(), data.length()*sizeof tjs_char); // converted string
				}
			}
		}
	}
예제 #2
0
파일: Main.cpp 프로젝트: xmoeproject/X-moe
	/**
	 * WAV録音準備
	 * @param filename 保存ファイル名
	 * @param channel チャンネル
	 * @param rate レート
	 * @param bits ビット数
	 * @param interval 取得タイミング
	 */
	void openWAV(const tjs_char *filename, int channel, int rate, int bits, int interval) {

		closeWAV();
		
		// ファイルを開く
		wvout = TVPCreateIStream(filename, TJS_BS_WRITE);
		
		// フォーマットを指定
		WAVEFORMATEX waveForm;
		waveForm.wFormatTag      = WAVE_FORMAT_PCM;
		waveForm.nChannels       = channel;
		waveForm.nSamplesPerSec  = rate;
		waveForm.wBitsPerSample  = bits;
		waveForm.nBlockAlign     = waveForm.nChannels * waveForm.wBitsPerSample / 8;
		waveForm.nAvgBytesPerSec = waveForm.nSamplesPerSec * waveForm.nBlockAlign;
		
		// waveIn を開く
		if (waveInOpen(&hwi, WAVE_MAPPER, &waveForm, (DWORD)waveInProc, (DWORD)this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
			TVPThrowExceptionMessage(L"waveInOpen");
		}
		
		/* キャプチャバッファ確保 */
		int length = waveForm.nAvgBytesPerSec * interval / 1000;
		wvhdr.lpData         = new char[length];
		wvhdr.dwBufferLength = length;
		wvhdr.dwFlags        = 0;
		wvhdr.reserved       = 0;

		// バッファを設定
		waveInPrepareHeader(hwi, &wvhdr, sizeof(wvhdr));
		waveInAddBuffer(hwi, &wvhdr, sizeof(wvhdr));
	}
예제 #3
0
파일: main.cpp 프로젝트: John-He-928/krkrz
// 実行ファイルがある場所に WHND を保存する
void
storeHWND(HWND hwnd)
{
	tTJSVariant varScripts;
	TVPExecuteExpression(TJS_W("System.exeName"), &varScripts);
	ttstr path = varScripts;
	path += ".HWND";
	IStream *stream = TVPCreateIStream(path, TJS_BS_WRITE);
	if (stream != NULL) {
		char buf[100];
		DWORD len;
		_snprintf(buf, sizeof buf, "%d", (int)hwnd);
		stream->Write(buf, strlen(buf), &len);
		stream->Release();
	}
}
예제 #4
0
//! opens the file
void CReadFile::openFile()
{
	if (Filename.size() == 0) // bugfix posted by rt
	{
		File = 0;
		return;
	}

	File = TVPCreateIStream(ttstr(Filename.c_str()), TJS_BS_READ);

	if (File)
	{
		// get FileSize
		STATSTG stat;
		File->Stat(&stat, STATFLAG_NONAME);
		FileSize = (long)stat.cbSize.QuadPart;
	}
}
예제 #5
0
void * psd_fopen(psd_char * file_name)
{
	return (void *)TVPCreateIStream(file_name, TJS_BS_READ);
}