summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-19 10:45:02 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-19 10:45:02 +0200
commitc484b0465c8c2298c8d439677412f34e6bdd17f1 (patch)
treec2cdda2aba8aedc9f56f417027b7c40612bd7e86 /source4/libcli
parent2fc058bdb0dd7d6ed2ffb17f049a677709d8be74 (diff)
downloadsamba-c484b0465c8c2298c8d439677412f34e6bdd17f1.tar.gz
samba-c484b0465c8c2298c8d439677412f34e6bdd17f1.tar.bz2
samba-c484b0465c8c2298c8d439677412f34e6bdd17f1.zip
Move SMB-specific attribute function to SMB client library.
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/rawfile.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index d39c61551b..d174fbfc28 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -30,6 +30,50 @@
if (!req) return NULL; \
} while (0)
+/**
+ Return a string representing a CIFS attribute for a file.
+**/
+_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
+{
+ int i, len;
+ const struct {
+ char c;
+ uint16_t attr;
+ } attr_strs[] = {
+ {'V', FILE_ATTRIBUTE_VOLUME},
+ {'D', FILE_ATTRIBUTE_DIRECTORY},
+ {'A', FILE_ATTRIBUTE_ARCHIVE},
+ {'H', FILE_ATTRIBUTE_HIDDEN},
+ {'S', FILE_ATTRIBUTE_SYSTEM},
+ {'N', FILE_ATTRIBUTE_NORMAL},
+ {'R', FILE_ATTRIBUTE_READONLY},
+ {'d', FILE_ATTRIBUTE_DEVICE},
+ {'t', FILE_ATTRIBUTE_TEMPORARY},
+ {'s', FILE_ATTRIBUTE_SPARSE},
+ {'r', FILE_ATTRIBUTE_REPARSE_POINT},
+ {'c', FILE_ATTRIBUTE_COMPRESSED},
+ {'o', FILE_ATTRIBUTE_OFFLINE},
+ {'n', FILE_ATTRIBUTE_NONINDEXED},
+ {'e', FILE_ATTRIBUTE_ENCRYPTED}
+ };
+ char *ret;
+
+ ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1);
+ if (!ret) {
+ return NULL;
+ }
+
+ for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) {
+ if (attrib & attr_strs[i].attr) {
+ ret[len++] = attr_strs[i].c;
+ }
+ }
+
+ ret[len] = 0;
+
+ return ret;
+}
+
/****************************************************************************
Rename a file - async interface
****************************************************************************/