makefile中如何判斷一個檔案是否存在
轉載:http://blog.csdn.net/qiaoliang328/article/details/7568141
makefile判斷檔案存在如下的兩種方法:
1. 呼叫shell的函式進行判斷
exist = $(shell if [ -f $(FILE) ]; then echo "exist"; else echo "notexist"; fi;)ifeq (exist, "exist")#do something hereendif當然,這個方法很土,但是能夠工作!!
2. 使用makefile的函式進行判斷
ifeq ($(FILE), $(wildcard $(FILE)))#do something hereendif
$(wildcard $(FILE))的意思是當前路徑下的檔名匹配FILE的檔案展開。
假設當前路徑下存在a.c 和 b.c,那麼執行src=$(wildcard *.c)
src的值就為a.c b.c;
如果不使用萬用字元,比如src=$(wildcard c.c);那麼就是要展開當前路徑下,檔名為c.c的檔案,因為當前路徑下檔案不存在,因此src為空字串。
相關推薦
C++中判斷一個檔案是否存在的方法
最進在寫的一個系統需要儲存結果資料,但是儲存結果資料的時候,如果那個資料已經存在,就會無法儲存,所以就需要先判斷是否存在該資料,判斷方法如下: #include<iostream> #include<fstream> using namespace
python中判斷一個檔案是否存在
你可以使用os.path.isfile,如果存在,它會返回True.如下: import os.path os.path.isfile(fname) 或者使用os.path.exists: import os.path os.p
makefile中如何判斷一個檔案是否存在
轉載:http://blog.csdn.net/qiaoliang328/article/details/7568141makefile判斷檔案存在如下的兩種方法:1. 呼叫shell的函式進行判斷exist = $(shell if [ -f $(FILE) ]; then
java中如何判斷一個檔案是二進位制檔案還是文字檔案?
現在的做法是把檔案讀進來,逐個解析每一個byte,如果有一個byte<0那麼斷定這個檔案是二進位制的,這在純英文的環境下可以工作,但是如果一個文字包含了中文字元,那麼這個檔案也會被判斷為二進位制檔案。 我在網上看看到有人也是逐個比較每一個byte,只不過是如果有一個b
NET中判斷一個文字檔案的編碼方式
檔案的字符集在Windows下有兩種,一種是ANSI,一種Unicode。 對於Unicode,Windows支援了它的三種編碼方式,一種是小尾編碼(Unicode),一種是大尾編碼(BigEndianUnicode),一種是UTF-8編碼。 我們可以從檔案的頭部來區分一個
C#中如何判斷一個檔案是否存在
新增引用using System.IO;你的strFileName裡已經是雙斜槓了 ,前面的@就不用了。 if(File.Exists(@"檔案路徑")) { //存在 } else { //不存在 }
freemarker中判斷一個字串是否包含另一個字串(select多選框資料回顯)
開發中用到了select多選框,所以資料回顯就要換一種方式解決。多選框返回的資料是一個用逗號分隔的字串,比如“a,b,c”,回顯的時候用contains判斷從而決定是否對每個option進行checked。 <#if "a,b,c,"?contains("a")>
c語言中判斷一個字串是否包含另一個字串
1. 使用庫函式 string.h strstr函式 函式名: strstr 功 能: 在串中查詢指定字串的第一次出現 用 法: char *strstr(char *str1, char
如何檢測或判斷一個檔案或位元組流(無BOM)是什麼編碼型別
前言: 不小心看到一條留言: 然後就去該地址看了一下,這一看,順帶折騰了一天。 今天,就和大夥分享下折騰的感覺。 在該開源地址中,程式碼有C++和C#兩個版本,編碼的整體風格傾向與於C++。 主要的時間,花了在對於檢測無BOM的部分,順帶重溫了各種編碼的基礎。 建議在看此文之前,先了解下編
ubuntu如何判斷一個檔案是32還是64位的
在系統當中,我們很多時候會困惑一個軟體是32還是64位的,很多時候軟體並沒有給出過於詳細的資訊,其實在ubuntu中,已經有很好的可以判斷一個程式到底是32還是64位的, 如圖 這裡的ELF 就是表明了我們的程式是多少位的,同樣我們可以使用file看檔案的型別。
Mysql中判斷一個欄位是不是為null注意點
今天查詢資料的時候,要查詢某一個欄位為null的情況,第一反應就是select * from xxx where xx = NULL; 這是不對的,資料是查不出來的,正確的應該是: se
python中判斷一個數字是否是質數
判斷一個數是否是質數,有很多方法,幾乎每一種語言都有關於判斷是否是質數的演算法,今天我向大家分享python中如何判斷一個數字是否是質數:首先要明白什麼是質數,質數是一個只能被自己和1整除的大於1的正整數。這裡要特別注意是大於1的數字,因為1不是質數。程式碼如下:#從控制
java中判斷一個字串是否為整型數字
/** * 判斷字串是否為數字 */ public static boolean isNumeric(String str){ Pattern patte
Python 中reload一個檔案時報錯 ( reload() argument must be module)
最近,在用reload()引入一個檔案時報如題的錯誤:(可能僅限於直接在Python自帶命令列中出現問題) 現在解決方案有兩種: 1、 from imp import reload import trees (trees為檔名,注意這裡不需要跟字尾名) reloa
使用seek()方法,將Hadoop檔案系統中的一個檔案在標準輸出上顯示兩次
wechat:812716131 ------------------------------------------------------ 技術交流群請聯絡上面wechat ----------------------------------------------
JS中判斷一個字串是否包含漢字
今天做專案的時候,用到一個對上傳的檔案的檔名不可以包含漢字 這種情況下,需要把上傳的檔案轉為unicode編碼在對unicode編碼進行判斷,漢字轉為unicode編碼都是以%u開頭的 在js中escape(str)可以把str轉換為unicode編碼 例子:var str
Javascript中判斷一個值是否為undefined的方法詳解
相信大家都知道當宣告一個變數,並且沒有給賦值的情況下,它的初始值是undefined。但是在javascript中,怎麼檢查一個值是否為undefined呢?簡單來說,在現代瀏覽器中,你可以安全的比較變數是否為undefined?1if (name === undefined
JQuery中判斷一個元素下面是否有內容或者有某個標籤的判斷程式碼
如下,怎麼判斷ul標籤內是否有內容?(下面的ul沒有內容) if($("ul[class$='XXX']").find("li").length==0){//如果class中包含“XXX”的ul標
js中判斷一個Object(包括function)有沒有某個屬性或者方法——hasOwnProperty()
<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/
在java中判斷一個字串中是否包含某個字元或字串
一、contains方法 java.lang.String.contains() 方法返回true,當且僅當此字串包含指定的char值序列 此方法返回true,如果此字串包含,否則返回false。 public static void main(String[] args