[C++] *.ncb 파일을 지우고 싶은데 remove 함수로 가능한가요?

cleitia의 이미지

remove함수를 사용하면 디렉토리나 파일을 지울 수 있는 것으로 알고 있는데요

특정 파일명을 정확히 알고 있어야 하나요?

가령
int remove(const char *pathname);
remove("a.txt"); 로 a.txt 파일을 삭제할 텐데요

저는 특정 확장자(.ncb)파일을 모두 지우고 싶습니다.
혹 파일명에 "*.txt"라고 하면 될까요.. 답변 부탁드립니다! ㅎ

shint의 이미지

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

shint의 이미지

.

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

gilgil의 이미지

프로그램을 작성하고 컴파일 & 링크 과정을 거치다 보면 임시 파일들이 생겨서 소스 관리에 어려운 부분이 많죠.
이 경우 batch file을 만들어 한꺼번에 임시 파일들을 삭제해 주면 편리합니다.
다음과 같은 내용을 _clear.bat 파일로 만들고 프로젝트 root 폴더에 넣은 다음에
그냥 탐색기에서 _clear.bat 파일을 실행(더블 클릭)해 주시면 하위 폴더까지 임시 파일들이 다 지워 집니다.

@echo off
rem --------------------------------------------------------
rem _cleat version 2013.04.22
rem Copyright (c) Gilbert Lee All rights reserved
rem --------------------------------------------------------
 
rem --------------------------------------------------------
rem common
rem --------------------------------------------------------
call :rm_file *.obj
call :rm_file *.user
call :rm_file *.ini
call :rm_file *.bak
call :rm_file *.log
call :rm_file *.xml
call :rm_file *.json
 
rem --------------------------------------------------------
rem borland
rem --------------------------------------------------------
call :rm_file *.~*
call :rm_file *.dcu
call :rm_file *.dsk
call :rm_file *.cfg
call :rm_file *.dsm
call :rm_file *.dcp
call :rm_file *.tds
call :rm_file *.#*
call :rm_file *.local
call :rm_file *.cgl
call :rm_file *.ilc
call :rm_file *.ild
call :rm_file *.ilf
call :rm_file *.ils
call :rm_file *.map
call :rm_file *.identcache
 
rem --------------------------------------------------------
rem microsoft
rem --------------------------------------------------------
call :rm_file *.pch
call :rm_file *.idb
call :rm_file *.pdb
call :rm_file *.exp
call :rm_file *.ilk
call :rm_file *.ncb
call :rm_file *.aps
call :rm_file *.plg
call :rm_file *.opt
call :rm_file *.bsc
call :rm_file *.sbr
call :rm_file *.dep
call :rm_file *.manifest
call :rm_file *.user
call :rm_file *.manifest.res
call :rm_file BuildLog.htm
call :rm_file /ah *.suo
 
rem --------------------------------------------------------
rem gcc
rem --------------------------------------------------------
call :rm_file *.o
 
rem --------------------------------------------------------
rem qt
rem --------------------------------------------------------
call :rm_file Makefile
call :rm_file Makefile.*
call :rm_file ui_*.h
call :rm_file qrc_*.cpp
call :rm_file moc_*.cpp
call :rm_folder GeneratedFiles
 
rem --------------------------------------------------------
rem other
rem --------------------------------------------------------
rem call :rm_file *.lib
rem call :rm_file *.exe
 
rem --------------------------------------------------------
rem folder
rem --------------------------------------------------------
call :rm_folder Debug
call :rm_folder debug
call :rm_folder Release
call :rm_folder release
call :rm_folder log
call :rm_folder __history
 
rem --------------------------------------------------------
rem epilogue
rem --------------------------------------------------------
goto :eof
 
rem --------------------------------------------------------
rem rm_file
rem --------------------------------------------------------
:rm_file
  del /s %1 %2 %3 %4 %5 %6 %7 %8 
goto :eof
 
rem --------------------------------------------------------
rem rm_folder
rem --------------------------------------------------------
:rm_folder
  set path=%1
  if not defined path goto :eof
  for /f "tokens=*" %%I in ('dir /b /s /ad %path%*') do if %%~nxI==%path% (
    rmdir /s /q "%%I"
  )
goto :eof

http://www.gilgil.net/9257

상기 URL에 가 보시면 windows batch 파일(_clear.bat)뿐만 아니라 linux shell 파일(_clear.sh)도 만들어 관리하고 있으니 참고하시기 바랍니다.

cleitia의 이미지

알려주신 방법으로 _clear.bat파일을 만들어서 실행보았는데

"rm_file은 외부, 내부 명령을 수행할 수 있는 프로그램 또는 배치파일이 아닙니다."

라는 메세지가 뜹니다..

Notepad++ 로 답변주신 내용 복사 붙여넣기 하고 bat파일로 저장을 했습니다.

하지만 실행을 하니 위와 같은 에러가 뜨는데 이유가 뭔지 알려주시면 감사하겠습니다!

cleitia의 이미지

응용프로그램인 Notepad++이 아닌 윈도우에서 기본으로 제공하는 Notepad 를 이용하여 코드 내용을 붙여넣고
.bat 파일로 저장했더니 잘 되네요!!

감사히 잘 쓰겠습니다^^

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.