Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:48:26+00:00 2026-05-15T13:48:26+00:00

The following NewLISP code shows me the file attributes of files under Win32. However,

  • 0

The following NewLISP code shows me the file attributes of files under Win32. However, some of the filenames retrieved have Chinese characters in the name. When the GetFileAttributesA function encounters them, it gives me a -1 for the attribute. I looked at GetFileAttributesW but don’t know how to make the contents of the fname available to the function in a form it recognises.

How does one handle this situation? (I am willing to consider trying another language)

(define (get-archive-flag file-name)
    (if (not GetFileAttributesA)
        (begin
        (import "kernel32.DLL" "GetFileAttributesA")
        )
    )
    (setq fname file-name file-attrib (GetFileAttributesA (address fname)))   
    (append fname " " ( string file-attrib))    
)

; walks a disk directory and prints all path-file names
;
(define (show-tree dir)
    (if (directory dir)
        (dolist (nde (directory dir))
            (if (and (directory? (append dir "/" nde))
                (!= nde ".") (!= nde ".."))
                (show-tree (append dir "/" nde))
                (println (get-archive-flag (append dir "/" nde)))
            )
        )
    )
)

(show-tree "z:\\working files\\Cathy")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:48:26+00:00Added an answer on May 15, 2026 at 1:48 pm

    For the sake of completeness, here’s the solution, found in consultation with the folk on the NewLISP forum.

    I haven’t replaced the bits slice reverse technique on the attribute bit with the more appropriate & operator. That’s left for the reader.

    (constant 'SIZEOF_WCHAR 2) ; assumption
    (constant 'CP_UTF8 65001)
    
    (define (utf8->16 lpMultiByteStr , cchWideChar lpWideCharStr ret)
        (if (not MultiByteToWideChar)
            (begin
            (import "kernel32.DLL" "MultiByteToWideChar")
            )
        )
        ; calculate the size of buffer (in WCHAR's)
        (setq cchWideChar 
            (
            MultiByteToWideChar
            CP_UTF8 ; from UTF-8
            0       ; no flags necessary
            lpMultiByteStr
            -1      ; convert until NULL is encountered
            0
            0
            )
        )
    
        ; allocate the buffer
        (setq lpWideCharStr (dup " " (* cchWideChar SIZEOF_WCHAR)))
    
        ; convert
        (setq ret 
            (
            MultiByteToWideChar
            CP_UTF8 ; from UTF-8
            0       ; no flags necessary
            lpMultiByteStr
            -1      ; convert until NULL is encountered
            lpWideCharStr
            cchWideChar
            )
        )
        (if (> ret 0) lpWideCharStr nil)
    )
    
    ; resets the Win32 archive flag on a file
    ; By CaveGuy 2009
    
    (define (get-archive-flag file-name)
        (if (not GetFileAttributesW)
            (begin
            (import "kernel32.DLL" "GetFileAttributesW")
            )
        )
        (setq fname file-name
            file-attrib (GetFileAttributesW (utf8->16 fname))
        )   
        file-attrib   
    )
    
    ; walks a disk directory and prints all path-file names where archive bit is set
    ;
    (define (show-tree dir)
        (if (directory dir)
            (dolist (nde (directory dir))
                (if (and (directory? (append dir "/" nde)) (!= nde ".") (!= nde "..") )
                    (show-tree (append dir "/" nde))
                    (if (not (or (= nde ".") (= nde "..")))
                        (begin
                        (setq fname (append dir "/" nde))
                        (setq fflag (get-archive-flag fname))
                        (setq fbits (bits fflag))
                        (if (= (slice (reverse fbits) 5 1) "1") (println fname))
                        )
                    )
                )
            )
        )
    )
    
    (show-tree "//server/folder")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a List<string> with 1500 strings. I am now using the following code
I have the following code: int takeEven(int *nums, int numelements, int *newlist) { newlist
I have the following C code to copy a linked list(taken from Stanford CS
I have the following code in VB for the QC API to Find tests
Following on from my last question : I've written some code to upgrade a
I have the following code which gives the warning in the title. I am
Following is the code snippet to copy txt file from a location to a
Following the steps given here , i have completed the installation process, however Python
Will the following code cause a ConcurrentModificationException or other side effects? ArrayList<String> newList =
Following code produces a nested array as a result for keys containing three items:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.