Linux stat函數和stat命令

来源:https://www.cnblogs.com/xiaoshiwang/archive/2019/04/24/10764243.html
-Advertisement-
Play Games

stat函數和stat命令 linux文件里的【inode = index node】解釋:要理解inode必須瞭解磁碟和【目錄項】,inode實際是連接【目錄項】和磁碟的中間物質。 圖裡的大圈代表硬體的磁碟,裡面的小圈代表某個文件存儲在磁碟上了。 【inode = index node】的node ...


stat函數和stat命令

linux文件里的【inode = index node】解釋:要理解inode必須瞭解磁碟和【目錄項】,inode實際是連接【目錄項】和磁碟的中間物質。

  • 圖裡的大圈代表硬體的磁碟,裡面的小圈代表某個文件存儲在磁碟上了。
  • 【inode = index node】的node(承載node信息的結構體是:stat,stat的定義在後面 )裡面有:
    • 文件大小
    • 文件的最後修改時間
    • 文件的所屬用戶
    • 文件的許可權
    • 硬鏈接計數(ls -l 顯示出來的數字)
    • 塊位置:指定文件存儲在磁碟的具體位置。
  • 下圖中的hello是個普通文件,hello.hard是hello的硬鏈接
  • 文件夾里放的就是每個文件的【目錄項】如下圖,【目錄項】里有:
    • 文件名
    • 該目錄項的大小
    • 文件的類型
    • inode

  • 如何查看文件的【inode】呢?使用【-i】選項

    ls -li 文件名

    執行結果:

    ys@ys-VirtualBox:~/lianxi1$ ls -li hello hello.hard 
    3801352 -rw-rw-r-- 2 ys ys 0 4月  24 11:01 hello
    3801352 -rw-rw-r-- 2 ys ys 0 4月  24 11:01 hello.hard

    發現hello和hello.hard的inode(3801352)是相同的,也就說明瞭,只在磁碟上存了一份。

  • 如何查看目錄項呢?用emacs或者vim打開目錄(lianxi1),截圖如下。但是看不到文件的【inode】。

1,stat函數:取得指定文件的文件屬性,文件屬性存儲在結構體stat里。

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int stat(const char *pathname, struct stat *statbuf);
int fstat(int fd, struct stat *statbuf);
int lstat(const char *pathname, struct stat *statbuf);

struct stat 結構體:

struct stat {
               dev_t     st_dev;         /* ID of device containing file */
               ino_t     st_ino;         /* Inode number */
               mode_t    st_mode;        /* File type and mode */
               nlink_t   st_nlink;       /* Number of hard links */
               uid_t     st_uid;         /* User ID of owner */
               gid_t     st_gid;         /* Group ID of owner */
               dev_t     st_rdev;        /* Device ID (if special file) */
               off_t     st_size;        /* Total size, in bytes */
               blksize_t st_blksize;     /* Block size for filesystem I/O */
               blkcnt_t  st_blocks;      /* Number of 512B blocks allocated */

               /* Since Linux 2.6, the kernel supports nanosecond
                  precision for the following timestamp fields.
                  For the details before Linux 2.6, see NOTES. */

               struct timespec st_atim;  /* Time of last access */
               struct timespec st_mtim;  /* Time of last modification */
               struct timespec st_ctim;  /* Time of last status change */

           #define st_atime st_atim.tv_sec      /* Backward compatibility */
           #define st_mtime st_mtim.tv_sec
           #define st_ctime st_ctim.tv_sec
           };
  • st_dev:設備ID,不太常用

  • st_ino:【inode】,【inode】是啥?不知道就看上面關於【inode】的解釋

  • st_mode:文件的類型和許可權,共16位,如下圖。

    • 0-11位控制文件的許可權

    • 12-15位控制文件的類型

    0-2比特位:其他用戶許可權

    3-5比特位:組用戶許可權

    6-8比特位:本用戶許可權

    9-11比特位:特殊許可權

    12-15比特位:文件類型(因為文件類型只有7中,所以用12-14位就夠了

文件類型的巨集如下(下麵的數字是8進位):

  • S_IFSOCK 0140000 socket
  • S_IFLNK 0120000 symbolic link(軟連接)
  • S_IFREG 0100000 regular file(普通文件)
  • S_IFBLK 0060000 block device(塊設備文件)
  • S_IFDIR 0040000 directory(目錄)
  • S_IFCHR 0020000 character device(字元設備文件)
  • S_IFIFO 0010000 FIFO(管道)
判斷文件類型的函數,返回true,false       
   S_ISREG(stat.st_mode)  is it a regular file?
   S_ISDIR(stat.st_mode)  directory?
   S_ISCHR(stat.st_mode)  character device?
   S_ISBLK(stat.st_mode)  block device?
   S_ISFIFO(m) FIFO (named pipe)?
   S_ISLNK(stat.st_mode)  symbolic link?  (Not in POSIX.1-1996.)
   S_ISSOCK(stat.st_mode) socket?  (Not in POSIX.1-1996.)

文件許可權的巨集如下:

       S_ISUID     04000   set-user-ID bit
       S_ISGID     02000   set-group-ID bit (see below)
       S_ISVTX     01000   sticky bit (see below)

       S_IRWXU     00700   owner has read, write, and execute permission
       S_IRUSR     00400   owner has read permission
       S_IWUSR     00200   owner has write permission
       S_IXUSR     00100   owner has execute permission

       S_IRWXG     00070   group has read, write, and execute permission
       S_IRGRP     00040   group has read permission
       S_IWGRP     00020   group has write permission
       S_IXGRP     00010   group has execute permission

       S_IRWXO     00007   others (not in group) have read,  write,  and
                           execute permission
       S_IROTH     00004   others have read permission
       S_IWOTH     00002   others have write permission
       S_IXOTH     00001   others have execute permission
  • st_nlink:硬連接計數

  • st_uid:這個文件所屬用戶的ID

  • st_gid:這個文件所屬用戶的組ID

  • st_rdev:特殊設備的ID,不太常用

  • st_size:文件的大小

  • st_blksize:不明是幹啥的

  • st_blocks:不明是幹啥的

  • struct timespec st_atim:最後訪問的時間

  • struct timespec st_mtim:最後修改的時間

  • struct timespec st_ctim:最後狀態改變的時間

    struct timespec {
      __kernel_time_t tv_sec;  /* seconds */當前時間到1970.1.1 00:00:00的秒數
      long        tv_nsec;    /* nanoseconds *//納秒數(不知道從哪到哪的)
    };
    1s  秒   = 1000ms 毫秒
    1ms 毫秒 = 1000us 微秒
    1us 微秒 = 1000ns 納秒

pathname:文件名

返回值:0代表成功;-1代表失敗,並設置error

例子:statbuf是結構體stat,可以看出來st_mode是個10進位的數字。

  • st_mode

    用gdb顯示st_mode,發現返回的st_mode是個10進位的數字,用gdb的【p/o】(o代表用8進位表示)命令把10進位的33204轉換成了8進位的【0100664】,第一個0代筆是8進位,後三位的【100】代表文件類型,從上面的說明可以看出來【100】代表普通文件,最後三位的【664】代表這個文件的許可權(本用戶:rw-,組用戶:rw-,其他用戶:r--)。所以從st_mode里就可以得知文件的類型和許可權設置(只使用了16個比特位,真的好節省空間,牛逼!)

  • st_uid

  • st_gid

    發現st_uid和st_gid是1000,但這個1000怎麼和用戶對應上呢,查看/etc/passwd文件,發現用於ys的uid和gid都是1000,所以就對應上了。

stat命令,是stat函數對應,執行結果如下:

ys@ys-VirtualBox:~/lianxi1$ stat hello
  File: hello
  Size: 11          Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d  Inode: 3801352     Links: 2
Access: (0764/-rwxrw-r--)  Uid: ( 1000/      ys)   Gid: ( 1000/      ys)
Access: 2019-04-24 17:02:39.199461489 +0800
Modify: 2019-04-24 16:54:16.407461489 +0800
Change: 2019-04-24 17:03:44.927461489 +0800

2,getpwuid函數:返回/etc/passwd文件里指定uid的行,把這一行的信息放入結構體passwd中。雖然返回值是指針,但不需要調用free函數。

#include <sys/types.h>
#include <pwd.h>
struct passwd *getpwnam(const char *name);
struct passwd *getpwuid(uid_t uid);

struct passwd {
  char   *pw_name;       /* username */
  char   *pw_passwd;     /* user password */
  uid_t   pw_uid;        /* user ID */
  gid_t   pw_gid;        /* group ID */
  char   *pw_gecos;      /* user information */
  char   *pw_dir;        /* home directory */
  char   *pw_shell;      /* shell program */
};

3,getgrgid函數:返回/etc/group文件里指定gid的行,把這一行的信息放入結構體group中。雖然返回值是指針,但不需要調用free函數。

#include <sys/types.h>
#include <grp.h>
struct group *getgrnam(const char *name);
struct group *getgrgid(gid_t gid);

struct group {
  char   *gr_name;        /* group name */
  char   *gr_passwd;      /* group password */
  gid_t   gr_gid;         /* group ID */
  char  **gr_mem;         /* NULL-terminated array of pointers
                             to names of group members */
};

4,localtime函數:傳入從stat函數里得到的st_mtim.tv_sec(當前時間到1970.1.1 00:00:00的秒數),得到結構體tm。雖然返回值是指針,但不需要調用free函數。

#include <time.h>
struct tm *localtime(const time_t *timep);
struct tm {
  int tm_sec;    /* Seconds (0-60) */
  int tm_min;    /* Minutes (0-59) */
  int tm_hour;   /* Hours (0-23) */
  int tm_mday;   /* Day of the month (1-31) */
  int tm_mon;    /* Month (0-11) */
  int tm_year;   /* Year - 1900 */
  int tm_wday;   /* Day of the week (0-6, Sunday = 0) */
  int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */
  int tm_isdst;  /* Daylight saving time */
};

5,lstat函數:stat碰到軟鏈接,會追述到源文件,穿透;lstat並不會穿透。

例子:模仿ls -l 文件

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <pwd.h>//getpwuid
#include <stdlib.h>
#include <time.h>//localtime
#include <grp.h>//getgrgid

int main(int argc, char* argv[]){

  struct stat sbuf;
  //stat(argv[1], &sbuf);
  lstat(argv[1], &sbuf);

  char str[11] = {0};
  memset(str, '-', (sizeof str - 1));
    
  //文件類型
  if(S_ISREG(sbuf.st_mode))  str[0] = '-';
  if(S_ISDIR(sbuf.st_mode))  str[0] = 'd';
  if(S_ISCHR(sbuf.st_mode))  str[0] = 'c';
  if(S_ISBLK(sbuf.st_mode))  str[0] = 'b';
  if(S_ISFIFO(sbuf.st_mode)) str[0] = 'p';
  if(S_ISLNK(sbuf.st_mode))  str[0] = 'l';
  if(S_ISSOCK(sbuf.st_mode)) str[0] = 's';

  //本用戶的文件許可權
  if(sbuf.st_mode & S_IRUSR) str[1] = 'r';
  if(sbuf.st_mode & S_IWUSR) str[2] = 'w';
  if(sbuf.st_mode & S_IXUSR) str[3] = 'x';
  
  //本用戶的組的文件許可權
  if(sbuf.st_mode & S_IRGRP) str[4] = 'r';
  if(sbuf.st_mode & S_IWGRP) str[5] = 'w';
  if(sbuf.st_mode & S_IXGRP) str[6] = 'x';
  
  //其他用戶的文件許可權
  if(sbuf.st_mode & S_IROTH) str[7] = 'r';
  if(sbuf.st_mode & S_IWOTH) str[8] = 'w';
  if(sbuf.st_mode & S_IXOTH) str[9] = 'x';

  char ymd[20] = {0};
  //取得日期和時間
  struct tm* tm = localtime(&sbuf.st_atim.tv_sec);
  sprintf(ymd, "%2d月  %2d %02d:%02d", tm->tm_mon + 1, tm->tm_mday,
      tm->tm_hour + 1,tm->tm_sec);
    
  //-rw-r--r-- 1 ys ys 134 4月  25 09:21 st2.c
  printf("%s %ld %s %s %ld %s %s\n", str, sbuf.st_nlink,
     getpwuid(sbuf.st_uid)->pw_name, getgrgid(sbuf.st_gid)->gr_name,
     sbuf.st_size, ymd, argv[1]);
  return 0;
}

6,access函數:判斷調用程式的用戶對於指定文件的許可權(可讀?可寫?可執行?)

#include <unistd.h>
int access(const char *pathname, int mode);
  • pathname:文件
  • mode
    • R_OK:可讀?
    • W_OK:可寫?
    • X_OK:可執行?
    • F_OK:文件存在?
  • 返回值
    • 查詢的許可權存在或者文件存在:返回0。
    • 查詢的許可權不存在或者文件不存在:返回-1。

例子:

#include <stdio.h>
#include <unistd.h>//access

int main(int argc, char* argv[]){
  if(access(argv[1], R_OK) == 0)
    printf("read ok\n");
  if(access(argv[1], W_OK) == 0)
    printf("write ok\n");
  if(access(argv[1], X_OK) == 0)
    printf("exe ok\n");
  if(access(argv[1], F_OK) == 0)
    printf("exists\n");
}
  • 先用ls -l 查看/usr/include/time.h文件的許可權,結果如下

    ys@ys-VirtualBox:~/lianxi$ ls -l /usr/include/time.h
    -rw-r--r-- 1 root root 10360 4月  17  2018 /usr/include/time.h
  • 用ys用戶執行例子程式,查看/usr/include/time.h文件,結果如下。因為time.h是屬於root用戶的,對於其他用戶來說是[r--],所以得出下麵的結果。

    ys@ys-VirtualBox:~/lianxi$ ./ac /usr/include/time.h
    read ok
    exists
  • 還是用ys用戶執行,但是加上sudo,結果如下。發現結果和root用戶相同。因為加了sudo,就編程了root用戶。

    ys@ys-VirtualBox:~/lianxi$ sudo ./ac /usr/include/time.h
    [sudo] password for ys: 
    read ok
    write ok
    exists

7,truncate函數:截斷文件和擴展文件的大小

#include <unistd.h>
#include <sys/types.h>
int truncate(const char *path, off_t length);
  • path:文件
  • length:
    • length大於原來文件的大小,則擴展文件的大小至length
    • length小於原來文件的大小,則截斷文件的大小至length

8,link函數:創建硬鏈接

#include <unistd.h>
int link(const char *oldpath, const char *newpath);

返回值:成功返回0,失敗返回-1,並設置errno。

9,symlink函數:創建軟鏈接

#include <unistd.h>
int symlink(const char *target, const char *linkpath);

返回值:成功返回0,失敗返回-1,並設置errno。

10,readlink函數:找到軟鏈接對應的實際文件,把文件的名字放入buf里。註意:硬鏈接不行。

#include <unistd.h>
ssize_t readlink(const char *pathname, char *buf, size_t bufsiz);

返回值:成功返回寫入buf的位元組數,失敗返回-1,並設置errno。

11,unlink函數:刪除軟硬鏈接,也可以刪除文件。

#include <unistd.h>
int unlink(const char *pathname);

返回值:成功返回0,失敗返回-1,並設置errno。

有個特殊用法:下麵的open代碼想要創建hello文件,然後直接用unlink刪除,但是能寫入成功,ret是大於0的,程式執行完,發現沒有做成hello文件。

結論:當執行unlink後,計數為0後,但,發現別的進程還引用這個文件,這個時間點,unlink不會刪除這個文件,等這個進程結束後,再刪除,所以下麵的write代碼能夠寫入成功。
利用這個特點可以實現:線上觀看視頻時,實際是把視頻文件下載到了本地(然後代碼里,使用unlink),看完後視頻文件的計數為0,就自動刪除了,不怕視頻被泄露出去。

#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(){
  int fd = open("hello", O_WRONLY | O_CREAT, 0666);
  unlink("hello");
  int ret = write(fd, "aaa", 4);
  if(ret > 0){
    printf("write OK\n");
  }
  
}

12,chown函數:改變文件的所屬用戶和組

#include <unistd.h>
int chown(const char *pathname, uid_t owner, gid_t group);
  • pathname:文件
  • owner:用戶ID(數字的)/etc/passwd
  • group:組ID(數字的)/etc/group
  • 返回值:0成功,-1失敗。

13,rename函數:重命名

#include <stdio.h>
int rename(const char *oldpath, const char *newpath);
  • oldpath :原來的文件名後者目錄
  • newpath:新的文件名後者目錄
  • 返回值:0成功,-1失敗。

14,getcwd函數:獲得當前工作的目錄

#include <unistd.h>
char *getcwd(char *buf, size_t size);
  • buf:當前工作的目錄
  • size:緩衝區大小
  • 返回值:
    • 成功返回當前工作的目錄
    • 失敗返回NULL

15,chdir函數:改變進程的工作目錄

#include <unistd.h>
int chdir(const char *path);
  • path:目標工作目錄
  • 返回值:0成功,-1失敗

16,mkdir函數:創建目錄

#include <sys/stat.h>
#include <sys/types.h>
int mkdir(const char *pathname, mode_t mode);
  • pathname:目標工作目錄
  • mode:mode & ~umask & 0777 。註意,如果沒有x許可權,則無法cd進入這個目錄。
  • 返回值:0成功,-1失敗

17,rmdir函數:刪除目錄,目錄必須是空目錄,也就是裡面沒有任何文件。

#include <unistd.h>
int rmdir(const char *pathname);

18,opendir函數:打開目錄

#include <sys/types.h>
#include <dirent.h>
DIR *opendir(const char *name);
  • name:目錄名
  • 返回值:a pointer to the directory stream

19,readdir函數:讀目錄

#include <dirent.h>
struct dirent *readdir(DIR *dirp);

struct dirent {
  ino_t          d_ino;       /* Inode number */
  off_t          d_off;       /* Not an offset; see below */
  unsigned short d_reclen;    /* Length of this record */
  unsigned char  d_type;      /* Type of file; not supported
                                 by all filesystem types */
  char           d_name[256]; /* Null-terminated filename */
};
  • dirp:opendir函數的返回值
  • 返回值:結構體dirent,可以理解成最上面說的【目錄項】
    • NULL代表讀到末尾或者有錯誤
    • NULL以外代表目錄項的內容

20,closedir函數:關閉目錄

#include <sys/types.h>
#include <dirent.h>
int closedir(DIR *dirp);
  • dirp:opendir函數的返回值

21,strerron函數:列印出errno對應的文字信息。

#include <string.h>
char *strerror(int errnum);
  • errnum的巨集放在文件:/usr/include/asm-generic/errno.h

例子:

#include <string.h>
#include <stdio.h>
#include <asm-generic/errno.h>//EDEADLK
int main(){
  char* buf = strerror(EDEADLK);
  printf("%s\n", buf);//Resource deadlock avoided
}

22,dup和dup2函數:文件描述符的重定向

#include <unistd.h>
int dup(int oldfd);
int dup2(int oldfd, int newfd);
  • dup:和open類似,先打開一個新的文件描述符,讓新的文件描述符也指向:oldfd指向的地方。
    • 成功返回新打開的文件描述符;失敗返回-1.
  • dup2:
    • 先消除newfd的指向
    • 再讓newfd指向oldfd指向的地方
    • 成功返回newfd;失敗返回-1.

例子:調用printf2次,第一次printf把內容寫到文件;第二次printf把內容列印到屏幕。

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(){

  int oldfd = dup(STDOUT_FILENO);
  int fd = open("www", O_WRONLY | O_CREAT, 0666);
  dup2(fd, STDOUT_FILENO);
  printf("aaaa\n");
  fflush(stdout);
  int ret = dup2(oldfd, STDOUT_FILENO);
  //int ret = dup2(oldfd, 6);
  //perror("dup2:");
  printf("reg:%d\n", ret);
  printf("aaaa\n");
  close(fd);
}

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 錯誤描述: 在VS2010執行讀取excel文件時,報錯“未在本地電腦上註冊“Microsoft.ACE.OLEDB.12.0”提供程式” 業務代碼: 報錯原因: 沒有安裝數據訪問組件,需要安裝相應版本的數據訪問組件(AccessDatabaseEngine) 解決方法: 下載安裝”Microso ...
  • 1、我們首先創建一個文件夾(用於保存本地倉) 在我們想要創建的路徑下右鍵滑鼠打開Git Bash Here(創建一個文件夾,併進入文件夾) 2、通過命令git init把我們剛纔創建的文件夾變成Git可管理的倉 之後會在剛纔創建的文件夾內看到多了一個 .git 的文件夾,這個文件夾的作用是用來跟蹤和 ...
  • 伺服器上有兩個介面,一個是Web Services(asmx文件)介面,一個是MVC API (普通的GET請求介面) 神奇的事情是這樣的,只要我使用WebRequest請求兩次,再使用Web Services 就超時,怎麼也不行。 ~~~C static void Main() { //連續兩次請 ...
  • 預設安裝Ubuntu都是不允許以root用戶進行登錄的,想要以root用戶進行登錄需要進行一些操作,主要是以下幾個步驟: 第一步 修改文件/usr/share/lightdm/lightdm.conf.d/50 unity greeter.conf文件,增加兩行: greeter show manu ...
  • 1.無線 運行powershell,輸入命令: 之後重啟。 運行cmd輸入: 2.音頻服務 運行cmd輸入: 如果已經操作完以上步驟後,你的無線或者音頻還不能使用,請重新安裝對應的驅動就可以了。 ...
  • 1、問題:There is no valid Xilinx installation that this Update can be applied to. 解決方法一:下載的是更新包,如果設備沒有預裝vivado的情況下就會出現這種問題;可以下載完整版本(Full Product Installa ...
  • 一、介紹 1、MIPI聯盟,即移動產業處理器介面(Mobile Industry Processor Interface 簡稱MIPI)聯盟。MIPI(移動產業處理器介面)是MIPI聯盟發起的為移動應用處理器制定的開放標準和一個規範。 2、MIPI聯盟定義了一套介面標準,把移動設備內部的介面如攝像頭 ...
  • 一、安裝Clamav殺毒工具 0、安裝Clamav需要的依賴包 yum install libxml openssl y 1、創建clamav組 groupadd clamav 2、創建clamav用戶 useradd g clamav clamav 3、解壓縮文件,得到clamav 0.100.2 ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...