void CodeWriter::operator+=(std::string text) { while (true) { auto begin = text.find("{{"); if (begin == std::string::npos) { break; } auto end = text.find("}}"); if (end == std::string::npos || end < begin) { break; } // Write all the text before the first {{ into the stream. stream_.write(text.c_str(), begin); // The key is between the {{ and }}. const std::string key = text.substr(begin + 2, end - begin - 2); // Find the value associated with the key. If it exists, write the // value into the stream, otherwise write the key itself into the stream. auto iter = value_map_.find(key); if (iter != value_map_.end()) { const std::string &value = iter->second; stream_ << value; } else { FLATBUFFERS_ASSERT(false && "could not find key"); stream_ << key; } // Update the text to everything after the }}. text = text.substr(end + 2); } if (!text.empty() && string_back(text) == '\\') { text.pop_back(); stream_ << text; } else { stream_ << text << std::endl; } }
static int do_chirp_acl_check(const char *filename, const char *subject, int flags, int follow_links) { char linkname[CHIRP_PATH_MAX]; char temp[CHIRP_PATH_MAX]; char dirname[CHIRP_PATH_MAX]; if(cfs->do_acl_check()==0) return 1; /* Symbolic links require special handling. If requested, follow the link and look for rights in that directory. */ if(follow_links && flags != CHIRP_ACL_DELETE) { int length = cfs->readlink(filename, linkname, sizeof(linkname)); if(length > 0) { linkname[length] = 0; /* If the link is relative, construct a full path */ if(linkname[0] != '/') { sprintf(temp, "%s/../%s", filename, linkname); string_collapse_path(temp, linkname, 1); } /* Use the linkname now to look up the ACL */ debug(D_DEBUG, "symlink %s points to %s", filename, linkname); filename = linkname; } } /* If the file being checked is an ACL file, then it may be written with the admin flag, but never deleted. */ if(!strcmp(string_back(filename, CHIRP_ACL_BASE_LENGTH), CHIRP_ACL_BASE_NAME)) { if(flags & CHIRP_ACL_DELETE) { errno = EACCES; return 0; } if(flags & CHIRP_ACL_WRITE) { flags &= ~CHIRP_ACL_WRITE; flags |= CHIRP_ACL_ADMIN; } } /* Now get the name of the directory containing the file */ string_collapse_path(filename, temp, 1); if(!cfs_isdir(temp)) string_dirname(temp, dirname); else strcpy(dirname, temp); /* Perform the permissions check on that directory. */ return chirp_acl_check_dir(dirname, subject, flags); }