Newer
Older
access-test / modules / main / src / test_delete.c
Nomura Kei on 9 Dec 2022 737 bytes UPDATE
/**
 * @file	test_create.c
 * @brief	create テスト
 * @author	Nomura Kei
 * @copyright 2008  Nomura Kei
 */
#include <stdio.h>
#include <errno.h>

#include <unistd.h>

#include <filetype.h>
#include <test_delete.h>


/**
 * 指定されたパスを削除します。
 * パスが存在しない場合は、errno に ENOENT が設定され、false を返します。
 *
 * @param pathname パス
 * @return true/false (生成成功/生成失敗)
 */
bool can_delete(const char* pathname)
{
	// パス存在有無確認 (存在しない場合 NG)
	bool is_error = !is_exists(pathname);
	if (is_error)
	{
		errno = ENOENT;
		return false;
	}

	// 削除
	int ret = remove(pathname);
	bool is_success = (ret == 0);
	return is_success;
}