Get the number of lines of code, picture resource list, and size in a project

Source: Internet
Author: User

-(Nsinteger) Codelineswithpath: (NSString *) path{nsfilemanager *filemanaget = [Nsfilemanager DefaultManager];    BOOL isdir = NO;        BOOL isexist = [Filemanaget fileexistsatpath:path isdirectory:&isdir];    if (!isexist) {return 0;                } if (Isdir) {//folder Nsarray *arr = [Filemanaget contentsofdirectoryatpath:path error:nil];                int sum = 0; For (NSString *filename in arr) {//file (clip) NSString *fullpath = [NSString stringwithformat:@ "%@/%@", p            Ath,filename];                    Sum + = [self codelineswithpath:fullpath];            } return sum;         }else{//File/* NSString *extension = [[path pathextension] lowercasestring]; if (! ( [Extension isequaltostring:@ "h"] | | [Extension isequaltostring:@ "M"] | | [Extension isequaltostring:@ "MM"]))         {return 0; } nsstring *content = [nsstring stringwithcontentsoffile:path encoding:Nsutf8stringencoding Error:nil];                  Nsarray *arr = [content componentsseparatedbystring:@ "\ n"];         return arr.count;        */NSString *extension = [[path pathextension] lowercasestring]; if (! ( [Extension isequaltostring:@ "png"] | | [Extension isequaltostring:@ "jpg"]))        {return 0; } nsstring *imagename = [path stringbyreplacingoccurrencesofstring:@]/users/xiaozeru/desktop/hkproject/res/        "withstring:@" "];        NSData *data = [NSData Datawithcontentsoffile:path];                NSLog (@ "IMAGENAME:%@--SIZE:%DKB", imagename,data.length/1024);            return 1; } return 0;}

Get the number of lines of code, picture resource list, and size in a project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.