#How can I include a file content as a string ?

10 messages · Page 1 of 1 (latest)

maiden pecan
#

Hello, it may be a stupid question, but I've no idea how to do it.
I want to include an external text file as a string at compile time in my program, but include_str("../../lib.atlas") doesn't work... and I've no idea what I should use for that. Do you happen to know any macros I can use to be able to build a correct file path that point this file so I can "feed" it to the include_str and get the file content?

obtuse flax
#

What's ur file structure like?

#

It's relative to the file the code is in, not the root

maiden pecan
#

It's in ./Atlas77 with in the Cargo.toml :

[workspace]
resolver = "1"
members = [
    "core/compiler",
    "core/runtime",
    "core/common",
    "core/atlas",
]
exclude = [
    "examples"
]

[profile.bench]
opt-level = 3
lto = true
codegen-units = 1
overflow-checks = false

wheat radish
#

The include_str! macro is in the lib.rs that you're showing here?

Can you show where the actual atlas/text file is you're trying to include? Files don't exist "within the Cargo.toml" so would need to see where that atlas file is located in your directory structure

It seems to be a case of the path just being wrong, so double check the path you send to include_str! as mentioned it's relative to the source file on disk rather than current working directory like they would be at runtime

obtuse flax
#

Which does not have a file named lib.atlas

maiden pecan
obtuse flax
#

Np