Ejemplo n.º 1
0
//デストラクタ
ModelManager::~ModelManager()
{
	//既にモデルデータが読み込まれているかの確認
	if (ModelFormat::UNDEFINED != m_ModelInfo.ModelFormat)
	{
		//作成されていれば念のため破棄処理する
		FileDataFree();

		//本来であれば破棄されているべきなので、警告メッセージを表示しておく
		WARNING_MESSAGE("破棄処理される前にデストラクタが呼ばれました。\n" \
						"破棄処理を忘れていませんか?\n");
	}
}
Ejemplo n.º 2
0
static int FilePruneFile(File *file)
{
    SCEnter();

    SCLogDebug("file %p, file->chunks_cnt %"PRIu64, file, file->chunks_cnt);

    if (!(file->flags & FILE_NOMAGIC)) {
        /* need magic but haven't set it yet, bail out */
        if (file->magic == NULL)
            SCReturnInt(0);
        else
            SCLogDebug("file->magic %s", file->magic);
    } else {
        SCLogDebug("file->flags & FILE_NOMAGIC == true");
    }

    /* okay, we now know we can prune */
    FileData *fd = file->chunks_head;

    while (fd != NULL) {
        SCLogDebug("fd %p", fd);

        if (file->flags & FILE_NOSTORE || fd->stored == 1) {
            file->chunks_head = fd->next;
            if (file->chunks_tail == fd)
                file->chunks_tail = fd->next;

            FileDataFree(fd);

            fd = file->chunks_head;
#ifdef DEBUG
            file->chunks_cnt--;
            SCLogDebug("file->chunks_cnt %"PRIu64, file->chunks_cnt);
#endif
        } else if (fd->stored == 0) {
            fd = NULL;
            SCReturnInt(0);
            break;
        }
    }

    /* file is done when state is closed+, logging/storing is done (if any) */
    if (file->state >= FILE_STATE_CLOSED &&
        (!RunModeOutputFileEnabled() || (file->flags & FILE_LOGGED)) &&
        (!RunModeOutputFiledataEnabled() || (file->flags & FILE_STORED)))
    {
        SCReturnInt(1);
    } else {
        SCReturnInt(0);
    }
}
Ejemplo n.º 3
0
static void FilePruneFile(File *file) {
    SCEnter();

    SCLogDebug("file %p, file->chunks_cnt %"PRIu64, file, file->chunks_cnt);

    if (!(file->flags & FILE_NOMAGIC)) {
        /* need magic but haven't set it yet, bail out */
        if (file->magic == NULL)
            SCReturn;
        else
            SCLogDebug("file->magic %s", file->magic);
    } else {
        SCLogDebug("file->flags & FILE_NOMAGIC == true");
    }

    /* okay, we now know we can prune */
    FileData *fd = file->chunks_head;

    while (fd != NULL) {
        SCLogDebug("fd %p", fd);

        if (file->flags & FILE_NOSTORE || fd->stored == 1) {
            file->chunks_head = fd->next;
            if (file->chunks_tail == fd)
                file->chunks_tail = fd->next;

            FileDataFree(fd);

            fd = file->chunks_head;
#ifdef DEBUG
            file->chunks_cnt--;
            SCLogDebug("file->chunks_cnt %"PRIu64, file->chunks_cnt);
#endif
        } else if (fd->stored == 0) {
            fd = NULL;
            break;
        }
    }

    SCReturn;
}
Ejemplo n.º 4
0
static int FilePruneFile(File *file)
{
    SCEnter();

    SCLogDebug("file %p, file->chunks_cnt %"PRIu64, file, file->chunks_cnt);

    if (!(file->flags & FILE_NOMAGIC)) {
        /* need magic but haven't set it yet, bail out */
        if (file->magic == NULL)
            SCReturnInt(0);
        else
            SCLogDebug("file->magic %s", file->magic);
    } else {
        SCLogDebug("file->flags & FILE_NOMAGIC == true");
    }

    /* okay, we now know we can prune */
    FileData *fd = file->chunks_head;

    while (fd != NULL) {
        SCLogDebug("fd %p", fd);

        if (file->flags & FILE_NOSTORE || fd->stored == 1) {
            /* keep chunks in memory as long as we still need to
             * inspect them or parts of them */
            if (file->flags & FILE_USE_DETECT) {
                uint64_t right_edge = fd->stream_offset + fd->len;
                if (file->content_inspected < right_edge)
                    break;
            }

            file->chunks_head = fd->next;
            if (file->chunks_tail == fd)
                file->chunks_tail = fd->next;

            FileDataFree(fd);

            fd = file->chunks_head;
#ifdef DEBUG
            file->chunks_cnt--;
            SCLogDebug("file->chunks_cnt %"PRIu64, file->chunks_cnt);
#endif
        } else if (fd->stored == 0) {
            fd = NULL;
            SCReturnInt(0);
            break;
        }
    }

    SCLogDebug("file->state %d. Is >= FILE_STATE_CLOSED: %s", file->state, (file->state >= FILE_STATE_CLOSED) ? "yes" : "no");

    /* file is done when state is closed+, logging/storing is done (if any) */
    if (file->state >= FILE_STATE_CLOSED &&
        (!RunModeOutputFileEnabled() || (file->flags & FILE_LOGGED)) &&
        (!RunModeOutputFiledataEnabled() || (file->flags & FILE_STORED)))
    {
        SCReturnInt(1);
    } else {
        SCReturnInt(0);
    }
}
Ejemplo n.º 5
0
/*-------------------------------------------------------------------------------
*	関数説明
*	 モデルファイルからモデルデータの読み込みを行います。
*	 既にモデルデータが読み込まれている場合は、データを破棄(メモリ解放)してから新しく読み込みします。
*	 読み込んだモデルデータの描画は「ModelDataDraw」関数で行います。
*	引数
*	 p_FileName	:[I/ ] 読み込みを行う拡張子付きのモデルファイル名
*							 [Resource/Model/]フォルダ以降のファイルパスを入力してください。
*							 また、ディレクトリをまたぐときは「/」で区切ってください(例「xxx/xxx.obj」)
*					   ※「p_ModelFormat」で自作モデルデータ(特殊パターン)を指定するときは、
*							「p_FileName」は「空("")」を指定してください。
*	 p_ModelFormat	:[I/ ] モデルファイルのフォーマット(詳細は定義部分のコメント参照)
*
*	戻り値
*	 なし
*-------------------------------------------------------------------------------*/
void ModelManager::FileDataLoad(const string &p_FileName, ModelFormat p_ModelFormat)
{
	printf("モデルデータ「%s」の読み込みを開始します...", p_FileName.c_str());

	//引数チェック
	if (ModelFormat::UNDEFINED == p_ModelFormat)
	{
		printf("失敗\n");
		ERROR_MESSAGE("モデルデータの読み込み 引数エラー\n" \
					  "p_FileName = %s, p_ModelFormat = %d\n", p_FileName.c_str(), p_ModelFormat);
		return;
	}

	//既にモデルデータが読み込まれているかの確認
	if (ModelFormat::UNDEFINED != m_ModelInfo.ModelFormat)
	{
		//作成されていれば破棄してから新規作成
		FileDataFree();

		//本来であれば上書きはしない事が多いので、警告メッセージを表示しておく
		WARNING_MESSAGE("モデルデータが再作成がされました。\n" \
						"破棄処理を忘れていませんか?\n");
	}

	///////////////////////////////
	// モデルファイルへのパスを作成

	string model_dir_file_name;			//モデルファイルへのパス

	//モデルファイルが指定されている場合(独自フォーマットの場合は作成しない)
	if (false == p_FileName.empty())
	{
		//モデルファイルへのパスを生成する(マルチバイト文字)
		model_dir_file_name = MODEL_FILE_DIR + p_FileName;
	}

	///////////////////////////////
	// モデルファイルの読み込み

	//読み込むフォーマットを記憶
	m_ModelInfo.ModelFormat = p_ModelFormat;

	//モデルファイルのフォーマットによって処理を分岐
	switch (p_ModelFormat)
	{
		//OBJファイル
		case ModelFormat::OBJ:
			FileLoad_OBJ(model_dir_file_name);
			break;

		//////////////////
		// 以下、自作モデルデータ(特殊パターン)

		//オリジナルフォーマットで穴あきのキューブデータ(エッジ有り)
		case ModelFormat::ORIGINAL_PIERCED_CUBE:
			DataLoad_PiercedCube();
			break;

		//オリジナルフォーマットで穴あきのキューブデータ(エッジ有り)
		case ModelFormat::ORIGINAL_PIERCED_CUBE2:
			DataLoad_PiercedCube2();
			break;

		default:
			printf("失敗\n");
			ERROR_MESSAGE("ピクセルフォーマットの引数が不正です。\n"\
						  "p_ModelFormat = %d", p_ModelFormat);

			break;
	}
}